Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using a table generated from Excel2Latex in my document. Despite using longtable, the table gets truncated at the end of page after overflowing the bottom margin. Min. working example provided below. It includes some minor modifications made by me to use the \sfrac command and adding a spacing of 1em after some rows.

\documentclass[a4paper]{scrartcl}

\usepackage{multirow}
\usepackage{longtable}
\usepackage{ctable}
\usepackage{hyphenat}
\usepackage{xfrac}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htb]
  \centering
  \caption{A long table}
    \begin{longtable}{cccccccc}
    \toprule
       Trial   &       & A     & B     & C     & D     & E     & Outcome \\
    \midrule
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 1}} & \multicolumn{1}{c}{A} & 1     & 1     & 9     & 9     & 9     & 0.01 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 9     & 9     & 9     & 0.01 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.05 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.05 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.05 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 2}} & \multicolumn{1}{c}{A} & 1     & 1     & 1     & 1     & 1     & 0.18 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 1     & 1     & 9     & 0.32 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 1     & 1     & 1     & 1     & 9     & 0.32 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 1     & 1     & 1     & 1     & 9     & 0.32 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 1     &  \sfrac{1}{9}  &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 0.06 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 3}} & \multicolumn{1}{c}{A} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 9     & 9     & 9     & 9     & 1     & 0.69 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 4}} & \multicolumn{1}{c}{A} & 1     & 7     & 9     & 9     & 9     & 0.65 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} &  \sfrac{1}{7}  & 1     & 5     & 5     & 5     & 0.20 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} &  \sfrac{1}{9}  &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} &  \sfrac{1}{9}  &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} &  \sfrac{1}{9}  &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.56 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 5}} & \multicolumn{1}{c}{A} & 1     &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 9     & 1     & 9     & 9     & 9     & 0.69 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 1     &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 1     &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 1     &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.08 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 6}} & \multicolumn{1}{c}{A} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 1     & 1     & 1     & 1     &  \sfrac{1}{9}  & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 9     & 9     & 9     & 9     & 1     & 0.69 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 7}} & \multicolumn{1}{c}{A} & 1     &  \sfrac{1}{3}  &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 0.04 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 3     & 1     &  \sfrac{1}{5}  &  \sfrac{1}{5}  & 3     & 0.10 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 9     & 5     & 1     & 1     & 9     & 0.41 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 9     & 5     & 1     & 1     & 9     & 0.41 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 1     &  \sfrac{1}{3}  &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 0.04 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 8}} & \multicolumn{1}{c}{A} & 1     &  \sfrac{1}{3}  & 5     &  \sfrac{1}{7}  & 5     & 0.13 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 3     & 1     & 9     & 1     & 9     & 0.35 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} &  \sfrac{1}{5}  &  \sfrac{1}{9}  & 1     &  \sfrac{1}{9}  & 1     & 0.04 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 7     & 1     & 9     & 1     & 9     & 0.45 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} &  \sfrac{1}{5}  &  \sfrac{1}{9}  & 1     &  \sfrac{1}{9}  & 1     & 0.04 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 9}} & \multicolumn{1}{c}{A} & 1     & 1     & 9     & 9     & 9     & 0.01 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 9     & 9     & 9     & 0.01 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.56 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 10}} & \multicolumn{1}{c}{A} & 1     & 1     & 9     & 9     & 9     & 0.03 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 9     & 9     & 9     & 0.08 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.30 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.30 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 1     & 1     & 1     & 0.30 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 11}} & \multicolumn{1}{c}{A} & 1     &  \sfrac{1}{9}  &  \sfrac{1}{9}  &  \sfrac{1}{9}  &  \sfrac{1}{9}  & 0.02 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 9     & 1     &  \sfrac{1}{5}  & 3     &  \sfrac{1}{3}  & 0.14 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 9     & 5     & 1     & 7     & 7     & 0.57 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 9     &  \sfrac{1}{3}  &  \sfrac{1}{7}  & 1     & 1     & 0.10 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 9     & 3     &  \sfrac{1}{7}  & 1     & 1     & 0.17 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 12}} & \multicolumn{1}{c}{A} & 1     & 5     & 9     & 9     & 9     & 0.62 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} &  \sfrac{1}{5}  & 1     & 5     & 5     & 5     & 0.22 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} &  \sfrac{1}{9}  &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} &  \sfrac{1}{9}  &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} &  \sfrac{1}{9}  &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.56 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 13}} & \multicolumn{1}{c}{A} & 1     &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.11 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 5     & 1     & 5     & 5     & 5     & 0.56 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 1     &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.11 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 1     &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.11 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 1     &  \sfrac{1}{5}  & 1     & 1     & 1     & 0.11 \\[1em]
    \multicolumn{1}{c}{\multirow{5}[0]{*}{Trial 14}} & \multicolumn{1}{c}{A} & 1     & 1     & 1     & 1     & 1     & 0.20 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{B} & 1     & 1     & 1     & 1     & 1     & 0.20 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{C} & 1     & 1     & 1     & 1     & 1     & 0.20 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{D} & 1     & 1     & 1     & 1     & 1     & 0.20 \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{E} & 1     & 1     & 1     & 1     & 1     & 0.20 \\[1em]
    \bottomrule
    \end{longtable}%
  \label{tab:addlabel}%
\end{table}%

\end{document}

Below is the output. Trials after 9 are missing.

output

share|improve this question
3  
a table is a minipage box it can not break over a page, you can not put longtable inside it. Just remove that environment \centering has no effect on longtable either. –  David Carlisle Mar 20 '13 at 19:59
1  
Has Exel2LaTeX build the table with environments table and longtable? Nevertheless, till today I have never seen a table from Exel2LaTex that has not to be reworked ... –  Kurt Mar 20 '13 at 21:19
    
@kurt Excel2latex, did add the table environment along with tabular. longtable was added by me in place of tabular. Tables have to be reworked, sure, but the macro is pretty convenient for long and complex tables such as these. –  Imad Mar 21 '13 at 13:19
add comment

1 Answer

up vote 0 down vote accepted

Thanks @David for the comment. The solution was to remove the table environment. So now I just have

\begin{longtable}{cccccccc}
... table contents ...
\end {longtable}

It works!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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