# Misalignment in a siunitx column with asterisks and different integer parts

In the following MWE the last number in the test statistic column, doesn't get aligned to the decimal separator. Although the additional asterisks are explicitly defined in the column definition. I tried a lot of different options, but could not get it to work properly.

\documentclass{article}
\usepackage{breqn}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{booktabs}
\begin{document}
\begin{table}[htb]
\newcommand{\ColWidthTestResults}{0.12}
\footnotesize
\sisetup{table-parse-only}
\begin{center}
\begin{tabularx}{\textwidth}{>{\centering}X
>{\centering}p{0.005\textwidth}
S[table-format=3.2
, table-number-alignment = center
, table-space-text-post = {$^{***}$}
, table-space-text-pre = {$^{***}$}
, round-precision=2
, round-integer-to-decimal = true
]
>{\centering}p{0.005\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
}
\toprule
rank       & & {test statistic} & & 10\% &  5\%  & 1\% \tabularnewline
\cmidrule{1-1}      \cmidrule{3-3}  \cmidrule{5 - 7}
r $\leq$ 2 & &   \num{2.88} & & 21.03 & 23.60 & 28.94\tabularnewline
r $\leq$ 1 & &  \num{23.58}     & & 42.20  & 45.54 &  52.27\tabularnewline
r $=$    0 & & \num{236.20}{$^{***}$}  & & 67.02 & 71.08  & 79.11 \tabularnewline
\bottomrule
\end{tabularx}\caption{Misaligned decimal separator}
\end{center}
\end{table}
\end{document}


Ideally the numbers should all be aligned on the decimal separator, no matter how many asterisks or how long the integer part of the decimals is.

• Remove  \sisetup{table-parse-only}… – Bernard Sep 2 '16 at 12:40
• That's not changing anything, it still is at least one digit off. – hannes101 Sep 2 '16 at 12:43
• I have no such problem. Which version of siunitx do you have? – Bernard Sep 2 '16 at 12:47
• I do have 2.6q installed. Just updating it now. – hannes101 Sep 2 '16 at 12:53
• Are you sure you compile the very code in your post, and nothing else? – Bernard Sep 2 '16 at 12:54

This code works fine for me. The culprit is \sisetup{table-parse-only}. I took the opportunity to make a few corrections to your code. In particular don't use a center environment inside table: it adds unwanted vertical spacings. Use \centering instead.

\documentclass{article}
\usepackage{breqn}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\begin{table}[!htb]
\newcommand{\ColWidthTestResults}{0.12}
\footnotesize
\centering
\begin{tabularx}{\textwidth}{>{\centering $}X<{$}S[table-format=3.2
, table-number-alignment = center
, table-space-text-post = {$^{***}$}
, table-space-text-pre = {$^{***}$}
, round-precision=2
, round-integer-to-decimal = true
]
>{\centering}p{\ColWidthTestResults\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
}
\toprule
\mathrm{rank} & {test statistic} & 10\,\% & 5\,\% & 1\,\% \tabularnewline%
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-5}
r \leq 2 & 2.88 & 21.03 & 23.60 & 28.94\tabularnewline
r \leq 1 & 23.58 & 42.20 & 45.54 & 52.27\tabularnewline
r = 0 & 236.20 {$^{***}$} & 67.02 & 71.08 & 79.11 \tabularnewline
\bottomrule
\end{tabularx}
\caption{Misaligned decimal separator}
\end{table}

\end{document}


To be honest, I do not quite understand why you are using the \num{} command in an S-column. Maybe I did not get what you are trying to do.

Do you want to achieve the following? Rounded values with alignment and some asterisks?

% arara: pdflatex

\documentclass{article}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}
\begin{table}[htb]
\newcommand{\ColWidthTestResults}{0.12}
\footnotesize
\begin{tabularx}{\textwidth}{>{\centering}X
S[table-format=3.2
,table-space-text-post = {***}
,round-mode=places
,round-precision=2
,table-align-text-post = false
]
>{\centering}p{\ColWidthTestResults\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
>{\centering}p{\ColWidthTestResults\textwidth}
}
\toprule
rank       & {test statistic} &  10\,\% &  5\,\%  & \SI{1}{\percent} \tabularnewline
\cmidrule(r){1-1}      \cmidrule{2-2}  \cmidrule(l){3 - 5}
r $\leq$ 2 &   2.88 &  21.03 & 23.60 & 28.94\tabularnewline
r $\leq$ 1 &  23.58     &  42.20  & 45.54 &  52.27\tabularnewline
r $=$    0 & 236.20111111*** &  67.02 & 71.08  & 79.11 \tabularnewline
\bottomrule
\end{tabularx}\caption{Perfectly aligned decimal separator}
\end{table}
\end{document}


I would advice you not to do the tabularx stuff and the font size tweaking, but I do not know, what your whole table looks like. For sure, I would tend to set the last three columns as S-columns as well. Or at least set the numbers in \num or  commands.

Here is what it looks like so far:

• I used \num during debugging and left it in the MWE, sorry about that. – hannes101 Sep 2 '16 at 14:00