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've been working on writing a contingency table in LaTeX (I've prepared myself for a long battle to get multi-line and multi-column cells to appear as I need).

\usepackage{booktabs}
\usepackage[detect-all]{siunitx}
\usepackage{multirow}

\begin{table}[htp]
    \centering
    \begin{tabular}{
           @{}
           l
           S[table-format=3.2]
           S[table-format=3.2]
           S[table-format=3.2]
           S[table-format=3.2]
           S[table-format=3.2]
           S[table-format=3.2]
           @{}
           }
        \toprule
        \multicolumn{7}{|c|}{Factor B} \\
        & Alpha & Beta & Gamma & Delta & Epsilon & Row Total \\

        \midrule
        \multirow{2}{*}{Alpha} & 1 & 1 & 1 & 1 & 1 & 1 \\
        & 11.11 & 2.11 & 3.11 & 4.11 & 5.11 & \\
        \multirow{2}{*}{Beta} & 2 & 2 & 2 & 2 & 2 & 2 \\
        & 22.22 & 2.22 & 3.22 & 4.22 & 5.22 & \\
        \multirow{2}{*}{Gamma} & 3 & 3 & 3 & 3 & 3 & 3 \\
        & 33.33 & 2.33 & 3.33 & 4.33 & 5.33 & \\
        \multirow{2}{*}{Delta} & 4 & 4 & 4 & 4 & 4 & 4 \\
        & 44.44 & 2.44 & 3.44 & 4.44 & 5.44 & \\
        \multirow{2}{*}{Epsilon} & 5 & 5 & 5 & 5 & 5 & 5 \\
        & 55.55 & 2.55 & 3.55 & 4.55 & 5.55 & \\
        Column Total & 111 & 222 & 333 & 444 & 555 & 666 \\

        \bottomrule
    \end{tabular}
    \caption {Table Caption}\label{my-table}
\end{table}

I receive the following error:

! siunitx Error

(siunitx) Invalid numerical input 'e'.

For immediate help type H <return>.
 ...                                              

l.157          & Alpha & Beta &
                                Gamma & Delta & Epsilon & Row Total \\

I admit I don't understand it. The non-numerical text is in the header of the table. To see the table, replace the line

    & Alpha & Beta & Gamma & Delta & Epsilon & Row Total \\

with

    1 & 2 & 3 & 4 & 5 & 6 & 7 \\

just to allow it to render.

I'm puzzled. Why "e"?

Suggestions are very appreciated.

Thanks in advance.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The "e" is because siunitx is trying to parse "Delta" as a number in engineering notation (eg, 1.234E+04). Fix it by writing the headings as \multicolumn{1}{c}{Delta}, etc

share|improve this answer
    
Thanks. Can you share how did you learn this? I certainly understand that trying to parse "Delta" as a number would fail but 2 more things are not clear to me: (a) why "D" was allowed (is it part of a numeric notation?) and (b) why wrapping the column labels in \multicolumn... worked. I wouldn't even have dreamed of doing that! –  wishihadabettername Oct 3 '10 at 11:49
    
a) I presume the problem is because the "e" of "Delta" looks like the exponential E of engineering notation. b) wrapping in \multicolumn{1}{c}{...} interprets the headings using the "c" column specifier instead of the "S[table-format=3.2]" specifier. –  Lev Bishop Oct 3 '10 at 15:41
2  
You can simply put header strings wrapped into curly brackets: & {Alpha} & {Beta} & {Gamma} & {Delta} & {Epsilon} & {Row Total} –  juanmah Feb 6 '12 at 15:24

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.