3

Is it possible to use \caption between a tabu environment?

I have tried using these packages:

\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}

And when I write this in my code:

\begin{tabu} spread 2in{|X[2]|X[2]|X|X|X[2]|X[2]|}
%\caption{Marito}
\hline
1 & 2 & 3 & 4 & 5 & 6 \\
\hline
\end{tabu}

I get a lot of errors if I uncomment \caption{Marito}.

Note: The Tabu documentation doesn't say anything about it

David Carlisle
  • 757,742
Mario S. E.
  • 18,609
  • 1
    No, it isn't, just like with tabular. The \caption doesn't belong in tabu or tabular. – egreg Mar 31 '13 at 20:17
  • 1
    If the table isn't breaking over the page surround the tabular (or tabu) with \begin{table}..\end{table} and put the caption in the table environment – David Carlisle Mar 31 '13 at 20:18

2 Answers2

3

As per @egreg and @David Carlisle, \caption cannot be used in a tabular environment. However, it is possible to used if wrapped around a \begin{table}... \end{table} environment as long as the table doesn't go in a pagebreak.

If so, longtabu can be used, and it has no problem with \caption.

Mario S. E.
  • 18,609
  • 1
    For captions without floats use package caption or capt-of instead, but outside of the tabular environment. – Speravir Apr 01 '13 at 00:09
1

tricky, though tabu, longtabu and longtable documentations definitely allow the \caption, but do not describe how to use them properly.

as mentioned by @cfr in another thread: put \\ behind the \caption[]{} -- worked for me!

(to be more precise: no errors, but the caption is formatted completely differnt than all others in the document. Maybe the caption package will solve that)

Mel
  • 91
  • 1