3

I have just discovered that I couldn't do alignment of the decimal points using the siunitx and longtable packages. It throws errors, just to mention some for e.g.:

Invalid numerical input 'e' Col1 & Col2 & n & Mean &    
Duplicate exponent marker token '\token_to_str:N d' in input Col1 & Col2 & n & Mean & Median &
Invalid numerical input 'edi' Col1 & Col2 & n & Mean & Median &
Overfull \hbox (9.16669pt too wide) detected  

This is a MWE of the problem stated above:

\documentclass{scrbook}
\usepackage[table-format=2.2]{siunitx}
\usepackage{longtable,booktabs}
\begin{document}
\begin{longtable}[l]{llcS[table-format=4.2]SSS} 
\caption{Some caption here for the long table.}\label{tab:somelabel}\\
\toprule
 Col1 & Col2 & n & Mean & Median & SD & P \\
\midrule
\endfirsthead
\midrule
Col1 & Col2 & n & Mean & Median & SD & P \\
\midrule
\endhead
\midrule
\endfoot
\midrule
\endlastfoot
 A & Negative &  18 & 38.90 & 2.53 & 3.53 & 0.12 \\
 A & Positive &  16 & 960.00 & 8.58 & 5.56 &  \\
 C & Negative &  18 & 98.50 & 1.14 & 1.48 & 0.75 \\
 C & Positive &  16 & 59.40 & 3.51 & 5.19 &  \\
 A & Negative &  18 & 13.70 & 3.98 & 5.12 & 0.20 \\
 A & Positive &  16 & 765.00 & 4.88 & 5.75 &  \\
 C & Negative &  18 & 33.80 & 2.64 & 3.85 & 0.10 \\
 C & Positive &  16 & 645.00 & 19.30 & 27.20 &  \\
 A & Negative &  18 & 25.90 & 5.30 & 6.77 & 0.98 \\
 A & Positive &  16 & 173.00 & 2.38 & 2.96 &  \\
 C & Negative &  18 & 182.00 & 9.10 & 13.30 & 0.03 \\
 C & Positive &  16 & 6676.00 & 69.20 & 101.00 &  \\
 A & Negative &  18 & 3.57 & 1.87 & 1.70 & 0.38 \\
 A & Positive &  16 & 108.00 & 1.93 & 1.51 &  \\
 C & Negative &  18 & 6.96 & 1.27 & 0.59 & 0.01 \\
 C & Positive &  16 & 143.00 & 3.71 & 4.30 &  \\
 A & Negative &  18 & 14.90 & 2.07 & 2.64 & 0.04 \\
 A & Positive &  16 & 693.00 & 7.03 & 8.37 &  \\
 C & Negative &  18 & 85.20 & 1.07 & 1.49 & 0.09 \\
 C & Positive &  16 & 295.00 & 16.50 & 23.70 &  \\
 A & Negative &  18 & 82.70 & 6.19 & 7.42 & 0.31 \\
 A & Positive &  16 & 1363.00 & 16.90 & 23.60 &  \\
 C & Negative &  18 & 63.70 & 2.15 & 2.78 & 0.03 \\
 C & Positive &  16 & 1101.00 & 24.40 & 34.70 &  \\
 A & Negative &  18 & 91.40 & 18.30 & 26.00 & 0.39 \\
 A & Positive &  16 & 3428.00 & 30.40 & 43.60 &  \\
 C & Negative &  18 & 37.00 & 11.90 & 17.60 & 0.84 \\
 C & Positive &  16 & 1822.00 & 7.26 & 10.60 &  \\
 A & Negative &  18 & 14.10 & 4.44 & 3.65 & 0.20 \\
 A & Positive &  16 & 404.00 & 4.27 & 5.22 &  \\
 C & Negative &  18 & 40.70 & 2.94 & 4.10 & 0.08 \\
 C & Positive &  16 & 769.00 & 21.30 & 30.20 &  \\
 A & Negative &  18 & 6.28 & 2.19 & 2.11 & 0.31 \\
 A & Positive &  16 & 397.00 & 5.25 & 7.63 &  \\
 C & Negative &  18 & 209.00 & 1.69 & 2.44 & 0.51 \\
 C & Positive &  16 & 809.00 & 11.80 & 16.40 &  \\
 A & Negative &  18 & 712.00 & 15.40 & 22.10 & 0.63 \\
 A & Positive &  16 & 3277.00 & 56.30 & 82.00 &  \\
 C & Negative &  18 & 2360.00 & 106.00 & 158.00 & 0.47 \\
 C & Positive &  16 & 4877.00 & 148.00 & 218.00 &  \\
 A & Negative &  18 & 20.10 & 4.08 & 5.19 & 0.08 \\
 A & Positive &  16 & 346.00 & 11.80 & 17.20 &  \\
 C & Negative &  18 & 4.63 & 1.03 & 1.05 & 0.03 \\
 C & Positive &  16 & 276.00 & 7.14 & 10.20 &  \\
\end{longtable}

\end{document}

Notes:

Texlive 2013
siunitx: Released 2013/07/11

1
  • As the problem obviously is not related to the Texstudio editor, I removed the references to it in the text. Commented Nov 11, 2013 at 14:59

1 Answer 1

4

For non-numerical content in S columns, you should generally enclose the content of the cells in braces ({}). In particular, siunitx uses the letter e for numbers with scientific notation, e.g. 2e3 for 2\times 10^3. This is the cause of the error you see. Hence, replace both cases of

Col1 & Col2 & n & Mean & Median & SD & P \\    

with

{Col1} & {Col2} & {n} & {Mean} & {Median} & {SD} & {P} \\

And your example compiles fine.

1
  • it works great!.
    – doctorate
    Commented Nov 11, 2013 at 14:13

You must log in to answer this question.

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