For the document shown below, I get the following error:
! Extra alignment tab has been changed to \cr.
l.103 \end{longtable}
and the output is garbled. However, this only happens if either of the following is true:
- the table actually breaks over multiple pages
- the table resides in a
\chapter
and the chapter style has been re-set tofancy
via\assignpagestyle{\chapter}{fancy}
The header also must contain a tabulary
as shown; the problem does not occur when there's a tabular(x)
, \includegraphics
, or anything else I could come up with.
I'm stumped, any ideas?
My document:
\documentclass[twoside,a4paper,11pt]{report}
\usepackage{longtable}
\usepackage{tabulary}
\usepackage[pagestyles]{titlesec}
\usepackage{fancyhdr}
% All pages in "main matter" will get this header:
\newcommand\mainmatter{
\fancyhead[CE,CO]{
\begin{tabulary}{6cm}{C}
\huge\fontencoding{T1}\fontfamily{phv}\selectfont PROJECT \\ \hline
\large Title\\
\end{tabulary}
}
}
% A titlesec command I use in the "real" document overwrites the
% chapter style, removing headers and footers. But I want those
% also on the chapter page, so:
\assignpagestyle{\chapter}{fancy}
\begin{document}
% Start "main matter" part
\mainmatter
\chapter{Some Chapter}
% Multi-page table
\begin{longtable}{llll}
\caption{Example of a problematic long table} \\
% Header on first page
\hline
\textbf{Head 1}&\multicolumn{3}{l}{\textbf{Head 2}} \\ \hline
\endfirsthead
% Header on subsequent pages
\multicolumn{4}{c}%
{{\textbf { \tablename\ \thetable{} } \tiny(continued from previous page)}} \\
\hline
\textbf{Head 1} & \multicolumn{3}{l}{\textbf{Head 2}} \\ \hline
\endhead
% Footer on all ut last page
\multicolumn{4}{r}{{\tiny{Continued on next page}}} \\ \hline
\endfoot
% Footer on last page
\hline\hline
\endlastfoot
% Table content
\textbf{data\_230} & \multicolumn{3}{l}{content\_1\_60} \\ \hline
\textbf{data\_240} & \multicolumn{3}{l}{content\_1\_60} \\ \hline
\textbf{data\_250} & \multicolumn{3}{l}{content\_1\_590} \\ \hline
\textbf{data\_260} & content\_1\_80 & content\_1\_240 & content\_1\_500 \\
& content\_1\_110 & content\_1\_440 & content\_1\_580 \\
& content\_1\_160 & content\_1\_500 & \\ \hline
\textbf{data\_270} & \multicolumn{3}{l}{content\_1\_650} \\ \hline
\textbf{data\_280} & content\_1\_90 & content\_1\_180 & content\_1\_450 \\
& content\_1\_120 & content\_1\_250 & content\_1\_510 \\
& content\_1\_170 & content\_1\_260 & content\_1\_600 \\ \hline
\textbf{data\_290} & content\_1\_740 & content\_1\_750 & \\ \hline
\textbf{data\_300} & content\_1\_20 & content\_1\_30 & content\_1\_430 \\ \hline
\textbf{data\_310} & \multicolumn{3}{l}{content\_1\_730} \\ \hline
\textbf{data\_530} & content\_2\_20 & content\_2\_100 & content\_2\_130 \\
& content\_2\_90 & content\_2\_110 & content\_2\_260 \\ \hline
\textbf{data\_550} & content\_1\_550 & content\_2\_150 & content\_2\_200 \\
& content\_2\_80 & content\_2\_160 & content\_2\_210 \\
& content\_2\_120 & content\_2\_170 & content\_2\_220 \\
& content\_2\_130 & content\_2\_180 & content\_2\_230 \\
& content\_2\_140 & content\_2\_190 & content\_2\_240 \\ \hline
\textbf{data\_560} & content\_1\_560 & content\_2\_260 & \\ \hline
\textbf{data\_580} & content\_1\_10 & content\_2\_60 & content\_2\_320 \\
& content\_1\_520 & content\_2\_300 & content\_2\_330 \\
& content\_1\_680 & content\_2\_310 & \\ \hline
\textbf{data\_600} & content\_2\_280 & content\_2\_290 & \\ \hline
\textbf{data\_610} & \multicolumn{3}{l}{content\_2\_270} \\ \hline
\textbf{data\_670} & \multicolumn{3}{l}{content\_1\_860} \\ \hline
\textbf{data\_780} & \multicolumn{3}{l}{content\_1\_850} \\ \hline
\textbf{data\_800} & content\_1\_520 & content\_1\_700 & content\_2\_300 \\
& content\_1\_680 & content\_2\_60 & content\_2\_320 \\
& content\_1\_690 & content\_2\_300 & \\ \hline
\textbf{data\_810} & content\_1\_870 & content\_1\_890 & content\_1\_910 \\
& content\_1\_880 & content\_1\_900 & \\ \hline
\textbf{data\_820} & content\_1\_870 & content\_1\_890 & content\_1\_910 \\
& content\_1\_880 & content\_1\_900 & \\ \hline
\textbf{data\_830} & content\_1\_710 & content\_1\_840 & \\ \hline
\textbf{data\_840} & content\_2\_380 & content\_2\_520 & \\ \hline
\textbf{data\_850} & content\_2\_380 & content\_2\_390 & \\ \hline
\textbf{data\_860} & \multicolumn{3}{l}{content\_1\_760} \\ \hline
\textbf{data\_860} & \multicolumn{3}{l}{content\_1\_770} \\ \hline
\textbf{data\_930} & \multicolumn{3}{l}{content\_2\_340} \\ \hline
\textbf{data\_950} & \multicolumn{3}{l}{content\_1\_660} \\ \hline
\textbf{data\_980} & \multicolumn{3}{l}{content\_1\_670} \\ \hline
\textbf{data\_990} & \multicolumn{3}{l}{content\_1\_720} \\ \hline
\textbf{data\_1000} & \multicolumn{3}{l}{content\_1\_720} \\ \hline
\end{longtable}
\end{document}
tabulary
for your header? And, since you loadtitlesec
withpagestyles
option, did you try withtitleps
, instead offancyhdr
?