1

I can make this work just fine with longtable, but I would like to use it with longtabu for some of its features.

Here's the code

\documentclass[11pt,a4paper]{book}

\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{caption}

\begin{document}

\begin{longtabu}{cc}
\rowcolor[gray]{.5} 
\caption{test}\endlastfoot
foo & bar\\
\end{longtabu}
\end{document}

If I comment out the rowcolor line, it works fine but the caption is not properly formatted.

I'm getting the following error ! Misplaced \noalign. \caption ->\noalign

I tried enclosing it in braces, putting some \expandafter around but nothing works. And it's all the more confusing when the longtabu documentation says \caption should work the same as with longtable, since it doesn't work here.

2
  • 1
    longtabu redefines \rowcolor. It no longer works before \multicolumn (used by \caption). Try \cellcolor inside the caption instead. Commented Apr 14, 2018 at 13:05
  • @UlrikeFischer it seems to be working if I put it inside indeed. It gave the same error if put outside, and I didn't think of putting it inside. Thanks, if you want to write an answer I'll give you a day, if you don't I'll write one to mark it as solved.
    – meneldal
    Commented Apr 14, 2018 at 13:45

1 Answer 1

4

longtabu redefines \rowcolor. It no longer works before \multicolumn (used by \caption). Try \cellcolor inside the \caption instead.

\documentclass[11pt,a4paper]{book}

\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{caption}

\begin{document}

\begin{longtabu}{cc}
\caption{\cellcolor{gray}test}\endlastfoot
foo & bar\\
\end{longtabu}
\end{document}
1
  • good to know! (+1)
    – Zarko
    Commented Apr 14, 2018 at 15:03

You must log in to answer this question.

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