[Tex/LaTex] How to put numbers in parenthesis in the S column using siunitx package

ctablesiunitxtablestabularx

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}

Best Answer

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