Incorrect numbering on table broken over pages using longtabu

I've a problem with table numbering when using longtabu and my tables go onto a second page. This was picked up by the external examiner in my viva - how embarassing!

Anyway, here's a MWE which should illustrate the issue.

I'm pretty sure it's the \caption command I've put in for the subsequent page headers. I included this to get the table number at the top of each page that the table is split over.

Is there a better way (correct way) of achieving the same result?

\documentclass[a4paper,12pt]{report}
\usepackage[top=3cm, bottom=3cm, left=4cm, right=2cm]{geometry} % sets margins
\usepackage{multirow} % allows merging of rows in tables
\usepackage{bigdelim} % Big delimiters in tables
\usepackage[margin=10pt, labelfont=bf, format=hang, textfont={small,it}]{caption} % for more interesting captions
\usepackage{rotating} % Allows rotating of figures and tables.
\usepackage{multirow} % allows merging of rows in tables
\usepackage{bigdelim} % Big delimiters in tables
\usepackage{longtable} % longtable allows tables to be split across pages
\usepackage{tabu} % Updated table environment, replaces ltablex
\usepackage{booktabs} % For professional looking tables
\usepackage{lscape} % landscape package

% Commands for use in tables
\newcommand{\rr}{\raggedright} % Left justification
\newcommand{\tn}{\tabularnewline} % New line command for use with \rr

\begin{document}

\begin{landscape}
\captionof{table}[Some data in a table where the numbering goes wrong.]{Some data in a table where the numbering goes wrong. }
\begin{longtabu}{XXXXX}
\toprule
\rr \textbf{Data 1}   & \rr \textbf{Data 2} & \rr \textbf{Data 3} & \rr \textbf{Data 4} & \rr \textbf{Data 5} \tn
\midrule
\caption{}[]\\
\toprule
\multicolumn{5}{r}{\small\sl \ldots continued from previous page} \\
\rr \textbf{Data 1}   & \rr \textbf{Data 2} & \rr \textbf{Data 3} & \rr \textbf{Data 4} & \rr \textbf{Data 5} \tn
\midrule
% footer for all but last page of table
\multicolumn{5}{r}{\small\sl continued on next page\ldots}\\
\bottomrule
\endfoot
%footer for last page of table
\bottomrule
\endlastfoot
% Table data
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\

\label{tab:numbers}
\end{longtabu}
\end{landscape}

\end{document}

-
I assume that longtabu operates just as longtable and that you need to include the caption inside! the longtabu environment. It implicitly says so in the docu "longtabu is based on the longtable package which must be loaded, and all features of the longtable environment works inside longtabu: \endhead, \endfirsthead, \endfoot, \endlastfoot and \caption." –  Martin H Feb 15 '12 at 19:56
Thanks for the comment. I realised this myself shortly before returning here to see if there were any responses. Can't remember why I started using \captionof outside of the longtabu environment. Seems a bit silly now that I think about it... –  Jon Stammers Feb 15 '12 at 21:15

What effect did you want to achieve? You have

    \caption{}[]


which is making an empty caption with a new number and then typesetting []

Just not having this command at all would fix the problem, but if you want a non-empty caption on later pages, use \caption[xxx]{yyy} or \caption*{...} depending on what you want to happen.

-
Thanks David. I've just seen the error in my ways before reading your post. Using \captionof{table}{...} and then \caption{} in subsequent page headings gives the behaviour I described above. I'm trying to think now why I used \captionof outside of the longtabu environment. There must have been a reason for it but it escapes me now. If I just use the \caption{} command for all table headers everything is fine! Thanks for your response. –  Jon Stammers Feb 15 '12 at 21:04

Problem solved (for my purposes anyway).

Using the \captionof{table} command outside of the longtabu environment seems to be the problem. If I just use \caption{} inside the longtabu environment all is well (see MWE below).

There must have been a good reason for me to use \captionof instead of \caption. Can't think what it was though...

\documentclass[a4paper,12pt]{report}
\usepackage[top=3cm, bottom=3cm, left=4cm, right=2cm]{geometry} % sets margins
\usepackage{multirow} % allows merging of rows in tables
\usepackage{bigdelim} % Big delimiters in tables
\usepackage[margin=10pt, labelfont=bf, format=hang, textfont={small,it}]{caption} % for more interesting captions
\usepackage{rotating} % Allows rotating of figures and tables.
\usepackage{multirow} % allows merging of rows in tables
\usepackage{bigdelim} % Big delimiters in tables
\usepackage{longtable} % longtable allows tables to be split across pages
\usepackage{tabu} % Updated table environment, replaces ltablex
\usepackage{booktabs} % For professional looking tables
\usepackage{lscape} % landscape package

% Commands for use in tables
\newcommand{\rr}{\raggedright} % Left justification
\newcommand{\tn}{\tabularnewline} % New line command for use with \rr

\begin{document}

\begin{landscape}
\begin{longtabu}{XXXXX}
% **** THIS HAS CHANGED ******
\caption[Some data in a table where the numbering goes wrong.]{Some data in a table where the numbering goes wrong. }\\
\toprule
\rr \textbf{Data 1}   & \rr \textbf{Data 2} & \rr \textbf{Data 3} & \rr \textbf{Data 4} & \rr \textbf{Data 5} \tn
\midrule
% **** THIS HAS CHANGED ******
\caption{}\\
\toprule
\multicolumn{5}{r}{\small\sl \ldots continued from previous page} \\
\rr \textbf{Data 1}   & \rr \textbf{Data 2} & \rr \textbf{Data 3} & \rr \textbf{Data 4} & \rr \textbf{Data 5} \tn
\midrule
% footer for all but last page of table
\multicolumn{5}{r}{\small\sl continued on next page\ldots}\\
\bottomrule
\endfoot
%footer for last page of table
\bottomrule
\endlastfoot
% Table data
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\
\midrule
1     & 1.1   & a     & 1     & 0.1 \\
&       & b     & 2     & 0.2 \\
& 1.2   & c     & 3     & 0.3 \\
&       & d     & 4     & 0.4 \\
& 1.3   & e     & 5     & 0.5 \\
&       & f     & 6     & 0.6 \\

\label{tab:numbers}
\end{longtabu}
\end{landscape}

\end{document}

-