Weird Spacing of Square Brackets and added .00s in Table with siunitx

alignmentsiunitxtables

I use the siunitx package to align numbers in a table column at their "dot". This used to work fine. When I re-compile an old TeX file, square brackets around the numbers are suddenly weirdly spaced and numbers in the column titles (I use numbers to label the columns) are transformed from (1) to (1.00).

Below I show the current result of siunitx with the weird spacing of brackets and the artificially added .00s. I also show a table which does not use siunitx and looks normal (but does not align numbers in a column at their dot).

Question: Was there an update to siunitx that changed how it works? How can avoid the odd spacing of square brackets and the adding of zeros in the column titles while aligning numbers at their dot?

enter image description here

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{output-exponent-marker = \text{e}, 
         exponent-product={}, 
         retain-explicit-plus, 
         input-open-uncertainty  = , 
         input-close-uncertainty = , 
         table-align-text-pre    = false,
         table-align-text-post = false, 
         round-mode=places, 
         round-precision=2, 
         table-space-text-pre = (, table-space-text-post   = )}

\begin{document}

\begin{table}
\begin{tabular}{l S @{} S @{} S @{} S @{} S @{} S @{} S @{} S @{} S} 
& (1) & (2) & (3) & (3)--(1) & & (4) & (5) & (6) & (6)--(4) \\ \midrule
Row 1 & 0.96  & 0.60  & 0.45  & -0.50 &       & 0.69  & 0.84  & 0.64  & -0.05 \\ \midrule
Row 2 & [3.93] & [2.75] & [1.93] & [-3.64] &       & [3.47] & [4.68] & [3.10] & [-0.59]
\end{tabular}
\end{table}


\begin{table}
\begin{tabular}{llllllllll}
& (1) & (2) & (3) & (3)--(1) & & (4) & (5) & (6) & (6)--(4) \\ \midrule
Row 1 & 0.96  & 0.60  & 0.45  & -0.50 &       & 0.69  & 0.84  & 0.64  & -0.05 \\ \midrule
Row 2 & [3.93] & [2.75] & [1.93] & [-3.64] &       & [3.47] & [4.68] & [3.10] & [-0.59]
\end{tabular}
\end{table}

\end{document}

Best Answer

Short answer: yes there have been many recent changes to siunitx. In this case, to avoid the decimalization of the top row, enclose the cell contents in braces.

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{output-exponent-marker = \text{e}, 
         exponent-product={}, 
         retain-explicit-plus, 
         input-open-uncertainty  = , 
         input-close-uncertainty = , 
         table-align-text-pre    = false,
         table-align-text-post = false, 
         round-mode=places, 
         round-precision=2, 
         table-space-text-pre = (, table-space-text-post   = )}

\begin{document}

\begin{table}
\begin{tabular}{l S @{} S @{} S @{} S @{} S @{} S @{} S @{} S @{} S} 
& {(1)} & {(2)} & {(3)} & {(3)--(1)} & & {(4)} & {(5)} & {(6)} & {(6)--(4)} \\ \midrule
Row 1 & 0.96  & 0.60  & 0.45  & -0.50 &       & 0.69  & 0.84  & 0.64  & -0.05 \\ \midrule
Row 2 & [3.93] & [2.75] & [1.93] & [-3.64] &       & [3.47] & [4.68] & [3.10] & [-0.59]
\end{tabular}
\end{table}


\begin{table}
\begin{tabular}{llllllllll}
& (1) & (2) & (3) & (3)--(1) & & (4) & (5) & (6) & (6)--(4) \\ \midrule
Row 1 & 0.96  & 0.60  & 0.45  & -0.50 &       & 0.69  & 0.84  & 0.64  & -0.05 \\ \midrule
Row 2 & [3.93] & [2.75] & [1.93] & [-3.64] &       & [3.47] & [4.68] & [3.10] & [-0.59]
\end{tabular}
\end{table}

\end{document}

enter image description here

To specify the format of the brackets, use table-format option to S. Of course, if there are multiple rows in play, you only get one S[table-format...] per column.

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{output-exponent-marker = \text{e}, 
         exponent-product={}, 
         retain-explicit-plus, 
         input-open-uncertainty  = , 
         input-close-uncertainty = , 
         table-align-text-pre    = false,
         table-align-text-post = false, 
         round-mode=places, 
         round-precision=2, 
         table-space-text-pre = (, table-space-text-post   = )}

\begin{document}

\begin{table}
\begin{tabular}{l S[table-format=2.2] @{} S[table-format=2.2] @{} 
  S[table-format=2.2] @{} S[table-format=3.2] @{} S[table-format=2.2] @{} 
  S[table-format=2.2] @{} S[table-format=2.2] @{} S[table-format=2.2] @{} 
  S[table-format=3.2]} 
& {(1)} & {(2)} & {(3)} & {(3)--(1)} & & {(4)} & {(5)} & {(6)} & {(6)--(4)} \\ \midrule
Row 1 & 0.96  & 0.60  & 0.45  & -0.50 &       & 0.69  & 0.84  & 0.64  & -0.05 \\ \midrule
Row 2 & [3.93] & [2.75] & [1.93] & [-3.64] &       & [3.47] & [4.68] & [3.10] & [-0.59]
\end{tabular}
\end{table}


\begin{table}
\begin{tabular}{llllllllll}
& (1) & (2) & (3) & (3)--(1) & & (4) & (5) & (6) & (6)--(4) \\ \midrule
Row 1 & 0.96  & 0.60  & 0.45  & -0.50 &       & 0.69  & 0.84  & 0.64  & -0.05 \\ \midrule
Row 2 & [3.93] & [2.75] & [1.93] & [-3.64] &       & [3.47] & [4.68] & [3.10] & [-0.59]
\end{tabular}
\end{table}

\end{document}

enter image description here

Related Question