[Tex/LaTex] Conflict between tabu and tabularx, when using siunitx

incompatibilitysiunitxtablestabutabularx

I have many tables set with {tabularx} but for some of the it seems easier to use {tabu} which works. But if I use both packages and gave the last X column in {longtabu} an S and optional argument it crashes.

So I can “unload” tabularx to make it work which is no option or use another tabular preamble but this isn’t so nice …

\documentclass{article}

\usepackage{tabu,longtable}
\usepackage{tabularx}% comment this out to make it work
\usepackage{siunitx}
\sisetup{locale=DE}

\begin{document}
%\begin{longtabu} to \textwidth{llX[-0.5,l]{S}X[-0.5,l]{S}X[-0.5,l]{S}}
% works with this preamble even when tabularx is loaded:
\begin{longtabu} to \textwidth{llX[-0.5,l]{S}X[-0.5,l]{S}X{S}}
    2&  1400&   2,5 &   1,0 &2,3\\
\end{longtabu}
\end{document}

I found How to use siunitx and tabularx together? but it doesn’t help.

Best Answer

tabularx is redefining \arraybackslash (and it even tells in the docu that this is a hack:

\arraybackslash \\ hack.
                 \def\arraybackslash{\let\\\@arraycr}

tabu doesn't like this definition. It expect \arraybackslash to have the meaning from array.sty. So now \\ gives errors. You can give \arraybackslash locally the standard definition back:

 \begingroup
 \def\arraybackslash{\let\\\tabularnewline}
 \begin{longtabu}
  ....
 \end{longtabu}
 \endgroup
Related Question