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

2
  • 1
    No, it isn't, just like with tabular. The \caption doesn't belong in tabu or tabular.
    – egreg
    Mar 31, 2013 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 Mar 31, 2013 at 20:18

2 Answers 2

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.

1
  • 1
    For captions without floats use package caption or capt-of instead, but outside of the tabular environment.
    – Speravir
    Apr 1, 2013 at 0: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)

1
  • Thats true it works fine.
    – J Leon V.
    Apr 9, 2018 at 17:11

You must log in to answer this question.

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