# Tabu embedding siunitx S columns into X columns doesn't work

I'm trying to make a table with S columns embedded into X columns. The MNWE is the following.

\documentclass[a4paper,12pt]{article}
\usepackage{array,tabu}
\usepackage{siunitx}

\begin{document}

\newcolumntype W{X[c]{S[round-mode=places, round-precision=2, round-integer-to-decimal=true]}}

\begin{tabu} to \linewidth {WW}
1      &2,356\\
4,567  &1234\\
\end{tabu}

\end{document}


I get the following error:

Package array Error: Illegal pream-token (S[round-mode=places,
round-recision=2, round-integer-to-decimal=true]): c' used.
\begin{tabu} to \linewidth {WW}


As soon as I remove the X column type like that:

\documentclass[a4paper,12pt]{article}
\usepackage{array,tabu}
\usepackage{siunitx}

\begin{document}

\newcolumntype W{S[round-mode=places, round-precision=2, round-integer-to-decimal=true]}

\begin{tabu} to \linewidth {WW}
1&2,356\\
4,567&1234\\
\end{tabu}

\end{document}


it works. But in that case I'm not getting X column formatting. What am I doing wrong? I've read some topics on similar matters but never found the solution to that problem.

• I'm afraid, that solution, which you like to obtain, doesn't exist. You can not mix S and any other columns type since they have different approach to defining column width. – Zarko Jul 12 '16 at 13:53
• @Maxim do you have also column headers in your table? In that case you could find a workaround adding \multicolumn{1}{p{.4\linewidth}}{Header A} & \multicolumn{1}{p{.4\linewidth}}{Header B} \\  or something similar. – CarLaTeX Jul 13 '16 at 6:40
• @Zarko, Tabu documentation is stating otherwise. This is an excerpt: A S column from siunitx can be embedded into a X column of τאb ... with the following limitations: • The X column must be centered: X[c] to keep the alignment, • The optional alignment parameter of \rowfont must not be used. – Maxim Jul 13 '16 at 15:17
• @CarLaTeX thank you! I'm sure there is a lot of workarounds, including the one suggested by you. But the functionality announced by Tabu documentation is very simple and attractive. So I just wonder, is it obsolete or I'm doing something wrong? – Maxim Jul 13 '16 at 15:23
• @Maxim, ypou have right. Reading of tabu documentation learn me, that I'm (partially) wrong. tabu support S column type, however not as you expected and it is advertised. It is known, that package is not maintained and buggy, so it seems that your first example has bug, the second one is actually standard table with S column types. – Zarko Jul 13 '16 at 17:51

What about a solution like this? (Ispired by David Carlisle's answer to this question: Combine column types defined in dcolumn with tabularx).

Even if a column header is needed...

\documentclass[a4paper,12pt]{article}
\usepackage{array}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\newcolumntype W{S[round-mode=places, round-precision=2, round-integer-to-decimal=true]}

\begin{tabularx}{\linewidth}{*{2}{W}}
\multicolumn{1}{X}{\centering col A} & \multicolumn{1}{X}{\centering col B} \\
\midrule %inserted only to show that the table is linewidth
1      &2,356\\
4,567  &1234\\
\end{tabularx}

\end{document}
`