5

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}%
  • You should rather use something like *{16}{r}, instead of rrrrrrrrrrrrrrrr. – Werner Mar 21 '13 at 21:36
  • The problem here is \caption inside longtable. Move it outside of the longtable environment. Why do you need a longtable for this not-so-long table? – Werner Mar 21 '13 at 21:38
  • @Werner I replaced what you provided and now I get ! LaTeX Error: Illegal character in array arg. – Jeel Shah Mar 21 '13 at 21:38
  • @Werner \caption is legal in longtable. – egreg Mar 21 '13 at 21:39
  • @egreg: Ahhh, right, but it's still the problem. From the longtable documentation: "The \caption{...} command is essentially equivalent to \multicolumn{n}{c}{\parbox{\LTcapwidth}{...}}." – Werner Mar 21 '13 at 21:40
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

  • 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. – user2478 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
  • 1
    using tabu makes no difference here – user2478 Mar 21 '13 at 21:58
  • 1
    @gekkostate see tex.stackexchange.com/questions/93808/… – David Carlisle Mar 21 '13 at 22:02
4

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

  • \endfirsthead might be better – user2478 Mar 21 '13 at 21:47
  • 1
    @Herbert yes perhaps, I just added something as the system complained I was under 30 characters:-) – David Carlisle Mar 21 '13 at 21:49
  • yes, 30 is too big for short answers :-) – user2478 Mar 21 '13 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.