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.

In the following minimal code, when I replace the l columns by S I get an error message saying

invalid-number!! Invalid numerical input '(4.36)'.!!
See the siunitx documentation for further information.!!

It goes on. It is important that I put the numbers in the third and fifth columns in parenthesis.

\documentclass{article}
\usepackage{booktabs}
\usepackage{ctable}
\usepackage{siunitx}
\usepackage{multirow}

\begin{document}
\ctable[
     caption = {caption here},
     label = {tab:tab1},
     pos = {!ht},
     center
] {@{}lS@{\enskip}>{(}l<{)}S@{\enskip}>{(}l<{)}}{
    \tnote[$\dagger$]{footnote here}
}{ \FL
\multirow{2}{*}{var} & \multicolumn{4}{c}{Title here} \\
\cmidrule{2-5}
    & \multicolumn{2}{c}{[AA]} & \multicolumn{2}{c}{[BB]} \ML       
$var_{12}$ & 1.37 & 4.36 & 1.50 & 8.91  \\
$var_{13}$ & 1.73 & 8.43 & 1.84 & 10.88 
\LL}
\end{document}
share|improve this question
    
try parse-numbers=false, numbers in (...) need to have a special format with siunitx as in 1.23(45), (4.36) does not follow this rule, thus the error. –  daleif Apr 9 at 9:35

2 Answers 2

up vote 5 down vote accepted

There are two things we should be careful about.

  1. parenthesis are used to indicate the uncertainty through the table-figures-uncertainty macro
  2. We can use table-parse-only to get the parsing only feature.

For item 1 above, we can hide ( and ) from siunitx by using braces → {(} and {)} so that they are not meant to indicate the uncertainty. table-parse-only gives correct spacing.

Code:

\documentclass{article}
\usepackage{booktabs}
\usepackage{ctable}
\usepackage{siunitx}
\usepackage{multirow}
%\sisetup{detect-weight=true,table-space-text-pre={(},table-space-text-post={)}}

\begin{document}
\ctable[
     caption = {caption here},
     label = {tab:tab1},
     pos = {!ht},
     center
] {@{}lS@{\enskip}>{{(}}S[table-parse-only]<{{)}}S@{\enskip}>{{(}}S[table-parse-only]<{{)}}}{
    \tnote[$\dagger$]{footnote here}
}{ \FL
\multirow{2}{*}{var} & \multicolumn{4}{c}{Title here} \\
\cmidrule{2-5}
    & \multicolumn{2}{c}{[AA]} & \multicolumn{2}{c}{[BB]} \ML
$var_{12}$ & 1.37 & 4.36 & 1.50 & 8.91  \\
$var_{13}$ & 1.73 & 8.43 & 1.84 & 10.88
\LL}
\end{document}

enter image description here

share|improve this answer
    
Just a side question, if I have another column beneath such as $var_4$ & \multicolumn{2}{}{23.568} & \multicolumn{2}{}{3.988} the S column does not recognize the last two cell entries as numbers. Is there a way to go about this? –  Duna Apr 9 at 9:52
    
@Duna When you use \multicolumn things are over ridden. –  Harish Kumar Apr 9 at 13:43

Instead of providing the option table-parse-only to the siunitx package, you could also provide the -- in my opinion less intrusive -- option input-symbols = (). Doing so tells siunitx to treat the symbols ( and ) as ordinary inputs, i.e., not to assign any special meaning to them (such as denoting uncertainty...).

Two nice features of this approach are (i) you needn't do anything special in the header information of the tabular environment in order to enter the parentheses in the body of the table and (ii) the ability of the siunitx package to align numbers on their decimal points (and to perform any other parsing tasks) is not affected.

enter image description here

\documentclass{article}
\usepackage{booktabs,siunitx}
\sisetup{input-symbols = ()} % "(" and ")" are ordinary inputs
\begin{document}
\begin{table}[ht!]
\caption{caption here} \label{tab:tab1}
\centering
\begin{tabular}{@{}lSSSS@{}}
\toprule
& \multicolumn{4}{c}{Title here} \\
\cmidrule{2-5}
& \multicolumn{2}{c}{[AA]} & \multicolumn{2}{c@{}}{[BB]} \\
\midrule
$var_{12}$ & 1.37 & (4.36) & 1.50 &  (8.91)\\
$var_{13}$ & 1.73 & (8.43) & 1.84 & (10.88)\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
share|improve this answer

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.