1

I would like to span a big table over two pages. When I use the longtable environment I cannot control the cell and font size. When I change the fontsize before the longtable starts font changes but the cell stay the same. Can someone help me to span the following table over two pages.

\documentclass[12pt,letter,notitlepage]{article}

\usepackage[flushleft]{threeparttable}
\usepackage{lipsum} 
\usepackage{tabularx}

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}[!htb]
\caption{\\ Example of a Very Long Table}
\label{tab:long_tale}
\centering
\footnotesize

\begin{threeparttable}

\begin{tabularx}{\linewidth}{lYYYY}
\hline \hline
& & & & \\
& (1) & (2) & (3) & (4) \\
& & & & \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
& & & & \\ \hline \hline
\end{tabularx}

\begin{tablenotes}

\fontsize{9pt}{9pt}\selectfont
\item
\textit{Notes:} \lipsum[2-4]  

\end{tablenotes}

\end{threeparttable}

\end{table}

\end{document}
2
  • Not going to happen, unless you manually split the contents over two table environments. A better question is how to control the fontsize and cell (\arraystretch ?) with longtable. Jun 6 at 4:20
  • There are longtable clones like ltxtable with support X (and therefore Y) columns. Jun 6 at 14:46

1 Answer 1

1

As @TrevorAndrew has already pointed out in a comment, you need to switch from a table/tabularx setup to a longtable setup.

Incidentally, I would place the long legend outside the longtable, in order to allow TeX to provide any needed pagebreaks freely, without being constrained by the longtable setup.

I would also align the numbers in the four data columns on their decimal markers.

I noticed that in your code, you set the width of the tabularx environment to \textwidth. I chose to mimic this behavior in the following code. Do let me know if this isn't necessary.

enter image description here

\documentclass[12pt,letterpaper]{article}

\usepackage{lipsum,booktabs,longtable,dcolumn} 
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}}

\begin{document}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}} l *{4}{d{2.3}} @{}}
\caption{Example of a Very Long Table} \label{tab:long_tale} \\
\toprule
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\
\midrule
\endfirsthead

\multicolumn{5}{@{}l}{(Table \thetable, cont'd)} \\
\toprule
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\
\midrule
\endhead

\bottomrule
\endlastfoot

\midrule
\multicolumn{5}{r@{}}{\raggedleft\footnotesize\em Cont'd on following page} \\
\endfoot

Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\*  % prevent page break
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 &  0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\

\end{longtable}
\begingroup
\noindent\footnotesize
\textit{Notes for Table \thetable}: \lipsum[2-3]\par
\endgroup

\end{document}
2
  • How can I can have two horizontal lines on top and the bottom and no horizontal line after (1) (2) (3) (4)? Also how can I change the font and cell size, e.g. to footnotesize. And if you already set the size to footnotesize where do I see it? Jun 7 at 3:41
  • 1
    @TrevorAndrew - Drawing two ill-spaced, thin horizontal lines instead of one well-spaced, slightly thicker horizontal line is nowadays considered to be rather old-fashioned. But if you insist, just replace both \toprule and \bottomrule with \hline\hline. If you don't want the line drawn by \midrule, then just omit both instances of that directive. If you want all material in the longtable environment to be rendered at footnote-type font size (why?), just insert \begingroup\footnotesize immediately before \begin{longtable} and \endgroup immediately after \end{longtable}.
    – Mico
    Jun 7 at 4:54

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.