6

I am using longtable and I am getting the error ! Extra alignment tab has been changed to \cr. I have attempted to fix it but nothing I have tried seems to be working. Below is the code for the table

  \centering
    \begin{longtable}{rrrrrrrrrrrrrrrrp{2cm}}
    \caption{A Table Depicting the Relationship between Meat, Fruit, Oil}
   Oil (Barrels) & Fruit (Ton) && Meat (Ton) & Fruit (Ton) && Meat (Ton) & Oil (Barrel) & Oil (Barrels) & Fruit (Ton) & & Meat (ton)  & Fruit (ton) &       & Meat (ton)  & Oil (barrel)  \\
\hline
    0     & 500   &       & 0     & 500   &       & 0     & 600   & 0     & 12050   &         & 0     & 12050 &       & 0     & 14460 \\
    10    & 491.5 &       & 50    & 466.6 &       & 50    & 560   & 1000  & 11216.6 &         & 1500  & 11050 &       & 1500  & 13260 \\
    24    & 480   &       & 100   & 433.3 &       & 100   & 520   & 2000  & 10383.3 &         & 3000  & 10050 &       & 3000  & 12060 \\
    42    & 465   &       & 150   & 400   &       & 150   & 480   & 3000  & 9550    &         & 4500  & 9050  &       & 4500  & 10860 \\
    48    & 460   &       & 200   & 366.6 &       & 200   & 440   & 4000  & 8716.6  &         & 6000  & 8050  &       & 6000  & 9660 \\
    50    & 458.3 &       & 250   & 333.3 &       & 250   & 400   & 5000  & 7883.3  &         & 7500  & 7050  &       & 7500  & 8460 \\
    75    & 437.5 &       & 300   & 300   &       & 300   & 360   & 6000  & 7050    &         & 9000  & 6050  &       & 9000  & 7260 \\
    100   & 416.6 &       & 350   & 266.6 &       & 350   & 320   & 7000  & 6216.6  &         & 10500 & 5050  &       & 10500 & 6060 \\
    150   & 375   &       & 400   & 233.3 &       & 400   & 280   & 8000  & 5383.3  &         & 12000 & 4050  &       & 12000 & 4860 \\
    200   & 333.3 &       & 450   & 200   &       & 450   & 240   & 9000  & 4550    &         & 13500 & 3050  &       & 13500 & 3660 \\
    250   & 291.5 &       & 500   & 166.6 &       & 500   & 200   & 10000 & 3716.6  &         & 15000 & 2050  &       & 15000 & 2460 \\
    300   & 250   &       & 550   & 133.3 &       & 550   & 160   & 11000 & 2883.3  &         & 16500 & 1050  &       & 16500 & 1260 \\
    400   & 166.6 &       & 600   & 100   &       & 600   & 120   & 12000 & 2050    &         & 18000 & 50    &       & 18000 & 60 \\
    500   & 83.3  &       & 650   & 66.6  &       & 650   & 80    & 13000 & 1216.6  &         & 18075 & 0     &       & 18075 & 0 \\
    600   & 0     &       & 700   & 33.3  &       & 700   & 40    & 14000 & 383.3   &         &       &       &       &       &  \\
          &       &       & 750   & 0     &       & 750   & 0     & 14460 & 0       &         &       &       &       &       & \\
\hline
\end{longtable}%
David Carlisle
  • 757,742
Jeel Shah
  • 3,794

2 Answers2

10

you forgot the double backslash after the \caption{...}\\

It is like a multicolumn an own line in a tabular.

Here is only an idea to get it smaller:

\documentclass[parskip=half]{scrartcl}
\usepackage{longtable,graphicx}
\def\RB#1{\rotatebox{90}{#1}}
\begin{document}

\begin{table}[!htb]
 \caption{A Table Depicting the Relationship between Meat, Fruit, Oil}

\resizebox{\linewidth}{!}{\tabcolsep=2pt%
 \begin{tabular}{*{16}r p{2cm}}
  \RB{Oil (Barrels)} & \RB{Fruit (Ton)} && \RB{Meat (Ton)} & \RB{Fruit (Ton)} && \RB{Meat (Ton)} & \RB{Oil (Barrel)} & \RB{Oil (Barrels)} & \RB{Fruit (Ton)} & & \RB{Meat (ton)}  & \RB{Fruit (ton)} &       & \RB{Meat (ton)}  & \RB{Oil (barrel)}  \\
\hline
    0     & 500   &       & 0     & 500   &       & 0     & 600   & 0     & 12050   &         & 0     & 12050 &       & 0     & 14460 \\
    10    & 491.5 &       & 50    & 466.6 &       & 50    & 560   & 1000  & 11216.6 &         & 1500  & 11050 &       & 1500  & 13260 \\
    24    & 480   &       & 100   & 433.3 &       & 100   & 520   & 2000  & 10383.3 &         & 3000  & 10050 &       & 3000  & 12060 \\
    42    & 465   &       & 150   & 400   &       & 150   & 480   & 3000  & 9550    &         & 4500  & 9050  &       & 4500  & 10860 \\
    48    & 460   &       & 200   & 366.6 &       & 200   & 440   & 4000  & 8716.6  &         & 6000  & 8050  &       & 6000  & 9660 \\
    50    & 458.3 &       & 250   & 333.3 &       & 250   & 400   & 5000  & 7883.3  &         & 7500  & 7050  &       & 7500  & 8460 \\
    75    & 437.5 &       & 300   & 300   &       & 300   & 360   & 6000  & 7050    &         & 9000  & 6050  &       & 9000  & 7260 \\
    100   & 416.6 &       & 350   & 266.6 &       & 350   & 320   & 7000  & 6216.6  &         & 10500 & 5050  &       & 10500 & 6060 \\
    150   & 375   &       & 400   & 233.3 &       & 400   & 280   & 8000  & 5383.3  &         & 12000 & 4050  &       & 12000 & 4860 \\
    200   & 333.3 &       & 450   & 200   &       & 450   & 240   & 9000  & 4550    &         & 13500 & 3050  &       & 13500 & 3660 \\
    250   & 291.5 &       & 500   & 166.6 &       & 500   & 200   & 10000 & 3716.6  &         & 15000 & 2050  &       & 15000 & 2460 \\
    300   & 250   &       & 550   & 133.3 &       & 550   & 160   & 11000 & 2883.3  &         & 16500 & 1050  &       & 16500 & 1260 \\
    400   & 166.6 &       & 600   & 100   &       & 600   & 120   & 12000 & 2050    &         & 18000 & 50    &       & 18000 & 60 \\
    500   & 83.3  &       & 650   & 66.6  &       & 650   & 80    & 13000 & 1216.6  &         & 18075 & 0     &       & 18075 & 0 \\
    600   & 0     &       & 700   & 33.3  &       & 700   & 40    & 14000 & 383.3   &         &       &       &       &       &  \\
          &       &       & 750   & 0     &       & 750   & 0     & 14460 & 0       &         &       &       &       &       & \\
\hline
\end{tabular}}%
\end{table}

\end{document}

enter image description here

Moriambar
  • 11,466
  • I have done that and now the error goes away but the table isn't wrapping to the next page, how can I fix that? I thought longtable automatically wrapped the table to the next page? – Jeel Shah Mar 21 '13 at 21:42
  • @gekkostate: longtable does it, but only in the vertical direction -> tabular lines. But not for columns! That can only be done by ConTeXt. –  Mar 21 '13 at 21:44
  • How can that be done? or Am I just better off splitting the table into two? – Jeel Shah Mar 21 '13 at 21:45
  • @gekkostate: It can be done when using ConTeXt instead of LaTeX. I suppose you should rotate your tabular. –  Mar 21 '13 at 21:46
  • USe the landscape environment or \rotatebox –  Mar 21 '13 at 21:52
  • I am looking at the wiki book for LaTeX and it recommends the tabu environment. What is your opinion? – Jeel Shah Mar 21 '13 at 21:54
  • 1
    using tabu makes no difference here –  Mar 21 '13 at 21:58
  • @gekkostate Oh you want to split vertically There is a an answer for that I'll find it – David Carlisle Mar 21 '13 at 22:01
  • 1
    @gekkostate see http://tex.stackexchange.com/questions/93808/column-wise-break-of-extra-wide-tables/93810#93810 – David Carlisle Mar 21 '13 at 22:02
5

You need \\ (or \endhead) after \caption{}

David Carlisle
  • 757,742