0

I am trying to make the following table span into two pages, but couldn't do so without making it very complicated (i.e., creating two separate tables). I have read that longtable would allow me to do so, but the issue is that I need to use some of the functionalities of Tabularx. Any suggestions how to make this work? Thanks in advance.

\documentclass[final,3p,times,12pt]{elsarticle}
\usepackage{booktabs,threeparttable}
\usepackage{color}
\usepackage[font=scriptsize]{caption}
\usepackage{mwe}
\usepackage{setspace}
\usepackage{pdflscape}
\usepackage{booktabs,calc}
\usepackage{color}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{adjustbox}
\usepackage{array}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{bbold}
\usepackage{lipsum}
\usepackage{blindtext} % to quickly get a full document
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\DeclareRobustCommand{\rchi}{{\mathpalette\irchi\relax}}
\newcommand{\irchi}[2]{\raisebox{\depth}{$#1\chi$}} % inner command, used by \rchi
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{dsfont}
\usepackage{bbm}
\newlength\mylength
\setlength\mylength{\dimexpr.6\columnwidth-3\tabcolsep-0.5\arrayrulewidth\relax}
\usepackage{etoolbox}
\patchcmd{\MaketitleBox}{\footnotesize\itshape\elsaddress\par\vskip36pt}{\footnotesize\itshape\elsaddress\par\parbox[b][33pt]{\linewidth}{\vfill\hfill\textnormal{\today}\hfill\null\vfill}}{}{}%
\patchcmd{\pprintMaketitle}{\footnotesize\itshape\elsaddress\par\vskip40t}{\footnotesize\itshape\elsaddress\par\parbox[b][40pt]{\linewidth}{\vfill\hfill\textnormal{\today}\hfill\null\vfill}}{}{}%
\usepackage{amssymb}





\begin{document}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Table NEW%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{table}[htb]

\vspace{-2.7cm}
\captionsetup{font=large} %footnotesize
  \caption{Coronavirus rates as a logarithmic function of social distancing}
  \vspace{-0.33cm}
\small   
    \begin{tabularx}{\linewidth}{l*{7}{Y}}

     \toprule {{\large{$\mathbbm{1}$}\small{(Death$_{j,t}$)}}}  \\
    \midrule
   & \textbf{(1)} & \textbf{(2)} & \textbf{(3)}  & \textbf{(4)} & \textbf{(5)}  & \textbf{(6)} & \textbf{(7)}  \\\hline 


{\large{$\mathbbm{1}$}\small{(Social Distancing$_{j,t}$)}}

 & 0.322& 0.278& 0.276 & 0.387*** & 0.304*** & 0.305*** & 0.381*** \\
 & (0.3333) & (0.2232) & (0.2323) & (0.333) & (0.334) & (0.334) & (0.333) \\


{\large{$\mathbbm{1}$}\small{(Pnst  Type$_{i}$)}} &  &  &  &  & 0.331*** & 0.331*** &  \\
 &  &  &  &  & (0.3359) & (0.3359) &  \\
{\large{$\mathbbm{1}$}\small{(Intense$_{i}$)}} &  &  &  &  & -0.3315 & -0.3313 &  \\
 &  &  &  &  & (0.3313) & (0.3313) &  \\
{\large{$\mathbbm{1}$}\small{(Intense 2l$_{i}$)}} &  &  &  &  & 0.0333 & 0.0336 &  \\
 &  &  &  &  & (0.0204) & (0.0204) &  \\
{\large{$\mathbbm{1}$}\small{(\Delta Intense 3$_{j,t}$)}} &  &  &  &  & 0.07** & 0.08** & 0.06* \\
 &  &  &  &  & (0.000) & (0.000) & (0.000) \\
 {\large{$\mathbbm{1}$}\small{(\Delta Insurance$_{j,t}$)}}&  &  &  &  & 0.133 & 0.149 & 0.114 \\
 &  &  &  &  & (0.090) & (0.090) & (0.091) \\
{\large{$\mathbbm{1}$}\small{(\Delta Gender$_{j,t}$)}} &  &  &  &  & 0.3*** & 0.3*** & 0.07** \\
 &  &  &  &  & (0.021) & (0.021) & (0.067) \\
{\large{$\mathbbm{1}$}\small{(\Delta Facility P$_{j,t}$)}} &  &  &  &  & 0.006 & 0.005 & 0.025** \\
 &  &  &  &  & (0.008) & (0.008) & (0.033) \\
{\large{$\mathbbm{1}$}\small{(\Delta Att$_{j,t}$)}} &  &  &  &  & 0.3345 & 0.0234 & 0.0215 \\
 &  &  &  &  & (0.038) & (0.042) & (0.333) \\
{\large{$\mathbbm{1}$}\small{(\Delta Ptt$_{j,t}$)}}&  &  &  &  & 0.0988 & 0.0849 & 0.0873 \\
 &  &  &  &  & (0.153) & (0.151) & (0.203) \\
{\large{$\mathbbm{1}$}\small{(\Delta Variable 3$_{[1,5],}$ $_{j,t}$)}} &  &  &  &  & 0.315 & 0.327 & 0.229 \\
 &  &  &  &  & (0.206) & (0.202) & (0.200) \\
{\large{$\mathbbm{1}$}\small{(\Delta Variable 3$_{(5,11],}$ $_{j,t}$)}} &  &  &  &  & -0.336 & 0.025 & 0.007 \\
 &  &  &  &  & (0.043) & (0.042) & (0.023) \\
{\large{$\mathbbm{1}$}\small{(\Delta Variable 3$_{(11,20],}$ $_{j,t}$)}}&  &  &  &  & -0.43** & -0.33** & -0.40** \\
 &  &  &  &  & (0.178) & (0.175) & (0.185) \\
{\large{$\mathbbm{1}$}\small{(\Delta Variable 3$_{(20,35],}$ $_{j,t}$)}}&  &  &  &  & 1.203** & 1.116** & 1.066* \\
 &  &  &  &  & (0.534) & (0.538) & (0.565) \\
{\large{$\mathbbm{1}$}\small{(\Delta Variable 3$_{>35},$ $_{j,t}$)}} &  &  &  &  & 0.020 & 0.030 & 0.003 \\
 &  &  &  &  & (0.0420) & (0.0433) & (0.0219) \\
{\large{$\mathbbm{1}$}\small{(\Delta Age Group 1$_{j,t}$)}}  &  &  &  &  & 0.291*** & 0.218** & 0.213** \\
 &  &  &  &  & (0.119) & (0.116) & (0.0846) \\
{\large{$\mathbbm{1}$}\small{(\Delta Age Group 2$_{j,t}$)}} &  &  &  &  & 0.3392 & 0.0823 & 0.0702 \\
 &  &  &  &  & (0.337) & (0.337) & (0.117) \\
{\large{$\mathbbm{1}$}\small{(\Delta Age Group 3$_{j,t}$)}} &  &  &  &  & 0.0250 & 0.0207 & 0.3379 \\
 &  &  &  &  & (0.021) & (0.021) & (0.023) \\
{\large{$\mathbbm{1}$}\small{(\Delta Age Group 4$_{j,t}$)}} &  &  &  &  & 0.0621 & -0.334 & -0.3355 \\
 &  &  &  &  & (0.120) & (0.339) & (0.121) \\
{\large{$\mathbbm{1}$}\small{(\Delta Age Group 5$_{j,t}$)}} &  &  &  &  & 0.137 & 0.355** & 0.123 \\
 &  &  &  &  & (0.160) & (0.157) & (0.166) \\
{\large{$\mathbbm{1}$}\small{(\Delta Doctor Age_{(30,49]},$_{j,t}$)}} &  &  &  &  & 0.004& 0.005 & 0.004 \\
 &  &  &  &  & (0.336) & (0.336) & (0.335) \\
{\large{$\mathbbm{1}$}\small{(\Delta Doctor Age_{>60},$_{j,t}$)}} &  &  &  &  & 0.004 & 0.009 & 0.005 \\
 &  &  &  &  & (0.031) & (0.030) & (0.028) \\
{\large{$\mathbbm{1}$}\small{(\Delta Prison Age$_{j,t}$)}} &  &  &  &  & 0.0287*** & 0.0283*** & 0.3346 \\
 &  &  &  &  & (0.004) & (0.004) & (0.009) \\
 {\large{$\mathbbm{1}$}\small{(\Delta Hospital Change$_{j,t}$)}} &  &  &  &  & 0.120*** & 0.121*** & 0.331** \\
 &  &  &  &  & (0.054) & (0.053) & (0.055) 
\\\hline 
\textbf{Fixed Effects} \\
Time &X&X&X&X&X&X&X \\
Country &&X&X&&X&X & \\
Time$\times$Country &&&X&&&X & \\
Location &&&&X&&&X 
\\\hline 
Number & 322,322 & 322,322 & 322,322 & 322,322 & 322,331 & 322,331 & 322,331 \\
 R-squared & 0.095 & 0.133 & 0.193 & 0.353 & 0.171 & 0.205 & 0.357 \\ \hline


    \bottomrule
\\

  \end{tabularx}
  Notes: *** $p<0.33$, ** $p<0.05$, * $p<0.1$. \textit{Robust Standard Errors} are in parentheses.

\end{table}





\clearpage



\end{document}
Job
  • 307
  • 1
    Take a look at xltabular. It combines the features of tabularx and longtable. – leandriis Mar 25 '20 at 20:41
  • 1
    Please be aware that your code does not compile properly. This is due to the use of \Delta outside of math mode. – leandriis Mar 25 '20 at 20:43
  • 1
    Out of curiosity: What's the purpose of {\large{$\mathbbm{1}$}? – leandriis Mar 25 '20 at 20:46
  • Many thanks, @leandriis. I see, I haven't tried before the packaged you kindly suggested. I will to a look at it and see how to make it work with my table. I assume your suggestion on an earlier question would also work well, right?

    https://tex.stackexchange.com/questions/497900/fitting-large-table-to-single-page

    – Job Mar 25 '20 at 20:57
  • When I just use {$\mathbbm{1}$}, the font was too small. So I modified it to {\large{$\mathbbm{1}$}. As well, great point about {\Delta}. I was running the code on the beamer and it seemed to work on there even without the $ signs. – Job Mar 25 '20 at 20:59
  • 1
    As soon as you get an error message, don't look at the pdf as there might be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error. Apart from the \Delta, also take a look at the _. These will also cause error messages. – leandriis Mar 25 '20 at 21:02
  • Also, one quick question @leandriis. Do you know of any post that has a sample code of xltabular that could create a similar table to what I am trying to do (i.e., multiple columns and multiple rules (i.e., toprule, etc.)? – Job Mar 25 '20 at 21:02
  • That's a good point. Indeed, the Beamer was giving an error message. Many thanks!! – Job Mar 25 '20 at 21:03
  • 1
    Since this question was just closed, I can't add an answer here. The syntax of xltabular is quite similar to longtable, so if you are already familiar with longtable, xltabular should be no problem. Apart from that and totally unrelated to the question, but please double check your preamble. Especially, make sure, you don't load packages more than once. You might also want to replace the \hlines in your table with \midrules for better spacing. You could also add \addlinespace after every other \\ in order to visually separate each set of value and error from the next set. – leandriis Mar 25 '20 at 21:18
  • 1
    Many thanks, @leandriis. You are always very kind and helpful. I will give it a try and ask a new question if I get stuck with it. – Job Mar 25 '20 at 21:30

0 Answers0