2

I am still struggling with my tables. My new problem is that I have a long table that should be split on more pages. I am trying to use the package longtable. The code I wrote so far is:

\documentclass{article}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage[labelfont=bf]{caption}
\usepackage[utf8]{inputenc}
\usepackage{caption, booktabs, makecell, siunitx}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[referable,para]{threeparttablex}
\usepackage[scale=.75]{geometry}
\captionsetup{font=bf}
\setlength{\textheight}{23.0cm}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, table-number-alignment =center}
\begin{document}
\begin{longtable}{l*{8}{c}}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{threeparttable}
\caption{Baseline model \label{table3}}
\centering\small
\hline\hline
 &\multicolumn{2}{c}{(a)}&\multicolumn{2}{c}{(b)}&\multicolumn{2}{c}{(c)}&\multicolumn{2}{c}{(d)}\\
&\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd Stage}&\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd Stage}\\
\hline
\endfirsthead
\multicolumn{9}{l}
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
&\multicolumn{2}{c}{(a)}&\multicolumn{2}{c}{(b)}&\multicolumn{2}{c}{(c)}&\multicolumn{2}{c}{(d)}\\
&\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd Stage}&\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd Stage}\\
\endhead
\hline \multicolumn{9}{l}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** \\(0.001)&0.011*** \\(0.001)\\
\hline \hline
\begin{tablenotes}
\item [] abc
\end{table}
\end{threeparttable}
\end{longtable}
\end{document}

However I receive the following error message

tab4_R.tex
20
Misplaced \noalign.
\caption ->\noalign 
                    \bgroup \@ifnextchar [{\egroup \LT@c@ption \@firstofone ...
l.20 \caption
             {Baseline model \label{table3}}

I cannot understand what is going wrong. Can anyone help me with this?

  • I get numerous errors with this. You might get better results from posting a working example. Stripping it down to a MWE is of course the best. – Runar Dec 30 '15 at 13:27
  • 4
    \end{table} \end{threeparttable} \end{longtable} you can not have either table or threeparttable inside longtable have you seen any documentation suggesting that should work? If so please give a link and we'll try to get the author to fix it. – David Carlisle Dec 30 '15 at 13:35
  • @DavidCarlisle yes you are right. \end{table} should not be there. Anyway even if I drop it, I still cannot have a longtable. – Dario Dec 30 '15 at 16:30
2

Use only environment longtable it can have footnotes, if really needed. And it can be inside \begin{landscape} ... \end{landscape} for very wide tabulars. Needs package pdflscape.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage[labelfont=bf]{caption}
\usepackage{caption, booktabs, makecell, siunitx}
\captionsetup{font=bf}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[scale=.75,textheight=23cm]{geometry}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, 
table-number-alignment =center}
\begin{document}
    \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
    \begin{longtable}{l*{8}{c}}
        \caption{Baseline model \label{table3}}\\\hline\hline
            &\multicolumn{2}{c}{(a)}&\multicolumn{2}{c}{(b)}&\multicolumn{2}{c}{(c)}&\multicolumn{2}{c}{(d)}\\
            &\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd 
            Stage}&\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd Stage}\\\hline
        \endfirsthead
            \hline
            &\multicolumn{2}{c}{(a)}&\multicolumn{2}{c}{(b)}&\multicolumn{2}{c}{(c)}&\multicolumn{2}{c}{(d)}\\
            &\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd 
                Stage}&\multicolumn{2}{c}{Fst Stage}&\multicolumn{2}{c}{Snd Stage}\\\hline
        \endhead
            \hline \multicolumn{9}{l}{\textit{Continued on next page}} \\
        \endfoot
            \hline\hline
        \endlastfoot
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
            SF                & 0.011*** \\(0.001)&0.011*** \\(0.001) &0.011*** 
            \\(0.001)&0.011*** \\(0.001)\\
    \end{longtable}
\end{document}
  • Thanks Herbert. The point is that I need to have a sideways table, as it is more good-looking. In addition, I should underline some elements in the headings. – Dario Dec 30 '15 at 16:32
  • no problem. Use the longtable inside \begin{landscape} ... \end{landscape}. Needs package pdflscape – user2478 Dec 30 '15 at 16:40

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.