7

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.

0

2 Answers 2

10

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
5
  • 3
    hey that's a revisionist view of history:-) TX defined \arraybackslash before there was a \tabularnewline so it's not really a re-definition, but yes your solution would work, no need to make it local it would work with TX as well. Feb 6, 2012 at 16:00
  • @DavidCarlisle and Ulrike: Thank you both! Works fine now :-)
    – Tobi
    Feb 6, 2012 at 16:25
  • @David I didn't wrote anything about the history but described the status of today: tabularx loads array and then overwrites \arraybackslash. But I now checked: The changes.txt of latex says that \tabularnewline was introduced 1994 (at your request). Why did tabularx never used it for \arraybackslash? And why did array use it when it included \arraybackslash in 2003 ("copied from tabularx")? Feb 6, 2012 at 16:32
  • 2
    "loads array then overwrites". Ah that's a bug I should just lose that line from TX. I think I added the command in all those places, but being consistent with yourself isn't easy, apparently. Feb 6, 2012 at 16:47
  • @UlrikeFischer Hopefully fixed the \arraybackslash issue: latex-project.org/svnroot/latex2e-public/required/tools/… Feb 7, 2012 at 0:29
7

I'm not sure what tabu is doing here (I didn't have it installed prior to this) but it looks like something is locally defining \\ so it no longer ends the table row. using \tabularnewline instead seems to make your example work.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .