0

I have a long table producing an error ("head or foot not at the start of table") at the line: \endlastfoot.

I can't figure out where is the problem. I will appreciate any insight.

My code is as follow (I cut the number of rows)

\begin{center}
\begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|p{}|}
\caption{Title}
\label{}
\\
\hline {d} & {W} & {R} &  {S} & {D} & {C1} & {C2} & {C3} & {A} & {N}\\
\endfirsthead
\hline\multicolumn{11}{|c|}
{{ \tablename \ \thetable{}--continued from previous page}}\\
\hline {d} & {W} & {R} &  {S} & {D} & {C1} & {C2} & {C3} & {A} & {N}\\
\endhead
\hline\multicolumn{11}{|c|}{{continued on next page}}\\
\hline
\endfoot
\hline
0 & 1 & 2 & 0 & 0 &  1 & 0 & 0 & 0 & 0 \\ \cline{1-11}
1 & 1 & 2.3476 & 1.4393 & 0.1864 &  0.8541 & 0.1459 & 0 & 0 & 0.0267 \\ \hline

\endlastfoot
\end{longtable}
\end{center}

The table is still producing error:

\begin{longtable}{|c|c|c|c|c|p{}|} 
\caption{}
\label{Spearman and distance correlation}
\\\hline{\small G} & {\small B)} &  {\small B} & {\small S (Group C)} & {\small  D} \\
\endfirsthead
\hline\multicolumn{5}{|c|}
{{ \tablename \ \thetable{} continued from previous page}}\\
\hline{\small G} & {\small B)} &  {\small B} & {\small S (Group C)} & {\small  D} \\
\hline
\endhead
\hline\multicolumn{5}{|c|}{{continued on next page}}\\
\hline
\endfoot
\hline
 TR & & & 0.64711267 & 0.6899505 \\\cline{1-5}
        CGR & 0.6605117 & 0.67962766 & &  \\\cline{1-5}
        C2 & 0.60588574 & 0.58207303 & &\\ \cline{1-5}
        C1 & 0.7528371 & 0.75355834 & 0.8530607 & 0.82074517 \\\cline{1-5}
        C2 & & & 0.65749854 & 0.63852245\\ \cline{1-5}
        CR & & & 0.61507607 & 0.63170303\\ \cline{1-5}
        IA1 & 0.56433934 & 0.5921317 & &\\ \cline{1-5}
        IR & 0.84881425 & 0.8601397 & & \\ \cline{1-5}
        I& 0.8097711 & 0.834002 & &\\ \cline{1-5}
        HSD17B1 vs IGF1R & 0.68974805 & 0.7168968 & & \\\cline{1-5}
        HGR & 0.62358147 & 0.6271943 & & \\\cline{1-5}
        HX & & & 0.61812353 & 0.65268934\\ \cline{1-5}
        H3 & & & 0.8229002 & 0.8185904 \\ \cline{1-5}
        R53 vs BCL2 & & & 0.6216794 & 0.6829379\\ \cline{1-5}
        RR & & & 0.6528702 & 0.69094443\\\cline{1-5}
        R3 vs LHCGR & 0.6127419 & 0.6288637 & 0.7181227 & 0.6854638\\\cline{1-5}
        C & 0.8374688 & 0.8288982 & & \\ \cline{1-5}
        R & 0.8382382 & 0.85765386 & & \\ \cline{1-5}
        B2 & 0.8405463 & 0.80230945 & & \\ \cline{1-5}
        FX & 0.71343875 & 0.7239513 & & \\ \cline{1-5}
        F1 & 0.7648222 & 0.7616126 & 0.5658618 & 0.65824085\\ \cline{1-5}
        R & 0.8428854 & 0.8250908 & & \\ \cline{1-5}
      \endlastfoot
      \end{longtable}
  • 1
    Welcome to TeX.SE! Delete the blank line before \endlastfoot. If that does not help please make your given code snippet compilable resulting in your issue. Then we can copy the code and test on our computers and play with it to find the error ... – Kurt Apr 18 at 13:20
  • you have no actual table here just head and foot with no body? also never put longtable in a center environment (it does not center it, it just adds spurious vertical space) – David Carlisle Apr 18 at 15:22
  • 1
    Even without correcting the errors Kurt and David told you, your code snippet, completed with a document class and loading longtable, gives no error to me: v2.overleaf.com/read/jfdthhhvpnby – CarLaTeX Apr 19 at 6:29
  • Hello, thank you all for your comments. I followed the link v2.overleaf.com/read/jfdthhhvpnby and to my surprise, I did not see any error. The only difference was that I removed many rows which I have in my table (I don't have an empty line between the last row with numbers and \endlastfoot command in my original table. I've deleted begin{center} but it didn't help. I put below full example. – Malgorzata Apr 19 at 15:12
1
  • in your table code snippet you have \endlastfoot on the end of table. correct is after \endfoot
  • you have defined 6 columns, but use only 5 (sixth not harm, however its definition p{} is wrong, you need to specify width of this column, for example p{1em})
  • since your table in columns 2 - 5 contains only numbers i suggest to use S column type defined in the siunitx package
  • instead \cline{1-5} in table width 5 columns you can use simpler/shorter \hline:

    \documentclass{article}
    \usepackage{makecell,   % new, for \thead
                longtable}
    \renewcommand\theadfont{\small}
    \usepackage{siunitx}
    \begin{document}
        \begin{longtable}{|c|*{4}{S[table-format=1.8]|}}    % p{1pt}|
    \caption{caption}
    \label{Spearman and distance correlation}                                       \\
        \hline
    \thead{G} & {\thead{B)}} & {\thead{B}} & {\thead{S (Group C)}} & {\thead{D}}    \\
        \hline
    \endfirsthead
        \hline
    \multicolumn{5}{|c|}{ \tablename \ \thetable{} continued from previous page}    \\
        \hline
    \thead{G} & {\thead{B)}} & {\thead{B}} & {\thead{S (Group C)}} & {\thead{D}}    \\
        \hline
    \endhead
        \hline
    \multicolumn{5}{|c|}{continued on next page}                                    \\
        \hline
    \endfoot
        \hline
    \endlastfoot
    TR  &               &               & 0.64711267& 0.6899505     \\  \hline
    CGR & 0.6605117     & 0.67962766    &           &               \\  \hline
    C2  & 0.60588574    & 0.58207303    &           &               \\  \hline
    C1  & 0.7528371     & 0.75355834    & 0.8530607 & 0.82074517    \\  \hline
    C2  &               &               & 0.65749854& 0.63852245    \\  \hline
    CR  &               &               & 0.61507607& 0.63170303    \\  \hline
    IA1 & 0.56433934    & 0.5921317     &           &               \\  \hline
    IR  & 0.84881425    & 0.8601397     &           &               \\  \hline
    I   & 0.8097711     & 0.834002      &           &               \\  \hline
    HSD17B1 vs IGF1R
        & 0.68974805    & 0.7168968     &           &               \\  \hline
    HGR & 0.62358147    & 0.6271943     &           &               \\  \hline
    HX  &               &               & 0.61812353& 0.65268934    \\  \hline
    H3  &               &               & 0.8229002 & 0.8185904     \\  \hline
    R53 vs BCL2
        &               &               & 0.6216794 & 0.6829379     \\  \hline
    RR  &               &               & 0.6528702 & 0.69094443    \\  \hline
    R3 vs LHCGR
        & 0.6127419     & 0.6288637     & 0.7181227 & 0.6854638     \\  \hline
    C   & 0.8374688     & 0.8288982     &           &               \\ \hline
    R   & 0.8382382     & 0.85765386    &           &               \\ \hline
    B2  & 0.8405463     & 0.80230945    &           &               \\ \hline
    FX  & 0.71343875    & 0.7239513     &           &               \\ \hline
    F1  & 0.7648222     & 0.7616126     & 0.5658618 & 0.65824085    \\ \hline
    R   & 0.8428854     & 0.8250908     &           &               \\
    \end{longtable}
    \end{document}
    

enter image description here

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.