What would be the recommended way to print a confidence interval as [x, y]
in an siunitx
S column? At the moment I have a two S column solution:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{table}[h]
\begin{tabular}{cS[table-format = 1.1]
S[table-format = -1.2, table-space-text-pre=[ ]@{}
S[table-format = -1.2, table-space-text-post=[, table-space-text-pre=[ ]
}
A & B & \multicolumn{2}{c}{CI} \\
Values & 2.3 & {[}1.23{,} & 1.23{]} \\
Values & 2.3 & {[}-3.42{,} & -2.43{]} \\
Values & 2.3 & {[}4.12{,} & 7.33{]} \\
Values & 2.3 & {[}-1.03{,} & -9.11{]} \\
\end{tabular}
\end{table}
\end{document}
Is there an easier siunitx
way?
Best Answer
You can make use of
table-space-text-pre
andtable-space-text-post
to make space for the square brackets. To insert the brackets before and after the columns, use the>{...}
and<{...}
syntax. To avoid wrong spacing before the last square bracket at each line, you have to use the TeX primitive\cr
instead og\\
to terminate the rows, as explained in section 7.13 of thesiunitx
manual.To center the column heading
B
you can simply put it in a group such as{B}
.