How to put numbers in parenthesis in the S column using siunitx package
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.
\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}
There are two things we should be careful about.
- parenthesis are used to indicate the uncertainty through the
table-figures-uncertainty
macro - We can use
table-parse-only
to get theparsing
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}