0

The following code creates a table that spans into two pages. However, I am running into three issues:

  1. The table does not fit into the page properly and is aligned in a strange way. I earlier used tabularx and that table was fitting well (on a given page, but was not spanning to the next page_. Although the post that @Werner re-directed me earlier provides some useful tips, I am running into these issues. Is there an easy way to solve this issue? To show that I want to achieve, please see the picture, Example 1, below (which was constructed using tabularx) that has the table properly centred.
  2. Similarly, the rows are also now not aligned and there are uneven gaps in between rows. Again, Example 1 does not run into such an issue.
  3. This is a minor question, but as in Example 1, the very first line is thicker than the below lines. Is there any way to do this with longtable (i.e., the code below)?

That said, I need to thank @leandriis for trying to help out earlier with a similar question. Although @leandriis kindly suggested that I should use xltabular, I was not able to find many useful examples that allows me to construct the table using this package. @leandriis, do you think the three above points can be solved with xltabular?

Thanks in advance for any suggestions!

Here is the code:

\documentclass[final,3p,times,12pt]{elsarticle}
\usepackage{caption}
\captionsetup{font=large} 
\usepackage{array}
\newcolumntype{M}[1]{>{\raggedright}m{#1}}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{bbm}
\usepackage{longtable}

\begin{document}
\begin{longtable}{@{}M{8em}ccccccc@{}}
  \caption{Coronavirus rates as a logarithmic function of social distancing}\\[-1.5ex]
  \multicolumn{7}{@{}p{\linewidth}@{}}{\footnotesize  Something something something something something something something something something something something something something something something something something something something something something something something something something something something something something. }  
  \\ [8ex]
\toprule
& \multicolumn{7}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\ 

 & (1) & (2) & (3) & (4) & (5) & (6)& (7) \\
\midrule
\endfirsthead
\multicolumn{7}{@{}l@{}}{continues from the previous page}\\
\midrule
& \multicolumn{7}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) \\

\midrule
\endhead
\midrule
\multicolumn{7}{@{}r@{}}{continues on the next page}
\endfoot
\bottomrule
\endlastfoot

$\mathbbm{1}${(Not 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) \\   
$\mathbbm{1}${(Pnst  Type$_{j,t}$)} &  &  &  &  & 0.331*** & 0.331*** &  \\
 &  &  &  &  & (0.3359) & (0.3359) &  \\   
$\mathbbm{1}${(Long variable name$_{j,t}$)} &  &  &  &  & -0.3315 & -0.3313 &  \\
 &  &  &  &  & (0.3313) & (0.3313) &  \\   
$\mathbbm{1}${(Intense 3$_{j,t}$)} &  &  &  &  & 0.07** & 0.08** & 0.06* \\
 &  &  &  &  & (0.000) & (0.000) & (0.000) \\  
 $\mathbbm{1}${(Insurance$_{j,t}$)}&  &  &  &  & 0.133 & 0.149 & 0.114 \\
 &  &  &  &  & (0.090) & (0.090) & (0.091) \\  
$\mathbbm{1}${(Gender$_{j,t}$)} &  &  &  &  & 0.3*** & 0.3*** & 0.07** \\
 &  &  &  &  & (0.021) & (0.021) & (0.067) \\  
$\mathbbm{1}${(Facility P$_{j,t}$)} &  &  &  &  & 0.006 & 0.005 & 0.025** \\
 &  &  &  &  & (0.008) & (0.008) & (0.033) \\  
$\mathbbm{1}${(Att$_{j,t}$)} &  &  &  &  & 0.3345 & 0.0234 & 0.0215 \\
 &  &  &  &  & (0.038) & (0.042) & (0.333) \\  
$\mathbbm{1}${(Ptt$_{j,t}$)}&  &  &  &  & 0.0988 & 0.0849 & 0.0873 \\
 &  &  &  &  & (0.153) & (0.151) & (0.203) \\  
$\mathbbm{1}${(Variable 3$_{[1,5],}$ $_{j,t}$)} &  &  &  &  & 0.315 & 0.327 & 0.229 \\
 &  &  &  &  & (0.206) & (0.202) & (0.200) \\  
$\mathbbm{1}${(Variable 3$_{(5,11],}$ $_{j,t}$)} &  &  &  &  & -0.336 & 0.025 & 0.007 \\
 &  &  &  &  & (0.043) & (0.042) & (0.023) \\  
$\mathbbm{1}${(Variable 3$_{(11,20],}$ $_{j,t}$)}&  &  &  &  & -0.43** & -0.33** & -0.40** \\
 &  &  &  &  & (0.178) & (0.175) & (0.185) \\  
$\mathbbm{1}${(Variable 3$_{(20,35],}$ $_{j,t}$)}&  &  &  &  & 1.203** & 1.116** & 1.066* \\
 &  &  &  &  & (0.534) & (0.538) & (0.565) \\  
$\mathbbm{1}${(Variable 3$_{>35},$ $_{j,t}$)} &  &  &  &  & 0.020 & 0.030 & 0.003 \\
 &  &  &  &  & (0.0420) & (0.0433) & (0.0219) \\  
$\mathbbm{1}${(Age Group 1$_{j,t}$)}  &  &  &  &  & 0.291*** & 0.218** & 0.213** \\
 &  &  &  &  & (0.119) & (0.116) & (0.0846) \\  
$\mathbbm{1}${(Age Group 2$_{j,t}$)} &  &  &  &  & 0.3392 & 0.0823 & 0.0702 \\
 &  &  &  &  & (0.337) & (0.337) & (0.117) \\  
$\mathbbm{1}${(Age Group 3$_{j,t}$)} &  &  &  &  & 0.0250 & 0.0207 & 0.3379 \\
 &  &  &  &  & (0.021) & (0.021) & (0.023) \\  
$\mathbbm{1}${(Age Group 4$_{j,t}$)} &  &  &  &  & 0.0621 & -0.334 & -0.3355 \\
 &  &  &  &  & (0.120) & (0.339) & (0.121) \\  
$\mathbbm{1}${(Age Group 5$_{j,t}$)} &  &  &  &  & 0.137 & 0.355** & 0.123 \\
 &  &  &  &  & (0.160) & (0.157) & (0.166) \\  

 \hline 

\midrule
\textbf{Fixed Effects} \\     
Time &X&X&X&X&X&X&X \\    
Country &&X&X&&X&X & \\    
Time$\times$Country &&&X&&&X & \\    
Location &&&&X&&&X \\    
\midrule
Observations & 16,175 & 16,175 & 16,158 & 16,059 & 15,041 & 15,041 & 14,941 \\  
 R-squared & 0.095 & 0.144 & 0.193 & 0.353 & 0.171 & 0.205 & 0.357 \\ \hline


\end{longtable}

\end{document}

enter image description here

Modification: Following the suggestion made by @Bernard, I have modified the code:

\documentclass{article}
\usepackage{caption}
\captionsetup{font=large} 
\usepackage{array}
\newcolumntype{M}[1]{>{\raggedright}m{#1}}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{bbm}
\usepackage{xltabular}
\usepackage{pdflscape}


\begin{document}
\begin{landscape}
\vspace*{-3cm}
\begin{xltabular}[l]{0.55\linewidth}{@{}X*8{c}@{}}
  \caption{Coronavirus rates as a logarithmic function of social distancing}\\[-1.5ex]
  \multicolumn{7}{@{}p{\linewidth}@{}}{\footnotesize  Something something something something something something something something something something something something something something something something something something something something something something something something something something something something something. }  \\ [8ex]
\toprule
& \multicolumn{8}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\ 

 & (1) & (2) & (3) & (4) & (5) & (6)& (7) \\
\midrule
\endfirsthead
\multicolumn{8}{@{}l@{}}{continues from the previous page}\\
\midrule
& \multicolumn{8}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) \\

\midrule
\endhead
\midrule
\multicolumn{8}{@{}r@{}}{continues on the next page}
\endfoot
\bottomrule
\endlastfoot

$\mathbbm{1}${(Not 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) \\   
$\mathbbm{1}${(Pnst  Type$_{j,t}$)} &  &  &  &  & 0.331*** & 0.331*** &  \\
 &  &  &  &  & (0.3359) & (0.3359) &  \\   
$\mathbbm{1}${(Long variable name$_{j,t}$)} &  &  &  &  & -0.3315 & -0.3313 &  \\
 &  &  &  &  & (0.3313) & (0.3313) &  \\   
$\mathbbm{1}${(Intense 3$_{j,t}$)} &  &  &  &  & 0.07** & 0.08** & 0.06* \\
 &  &  &  &  & (0.000) & (0.000) & (0.000) \\  
 $\mathbbm{1}${(Insurance$_{j,t}$)}&  &  &  &  & 0.133 & 0.149 & 0.114 \\
 &  &  &  &  & (0.090) & (0.090) & (0.091) \\  
$\mathbbm{1}${(Gender$_{j,t}$)} &  &  &  &  & 0.3*** & 0.3*** & 0.07** \\
 &  &  &  &  & (0.021) & (0.021) & (0.067) \\  
$\mathbbm{1}${(Facility P$_{j,t}$)} &  &  &  &  & 0.006 & 0.005 & 0.025** \\
 &  &  &  &  & (0.008) & (0.008) & (0.033) \\  
$\mathbbm{1}${(Att$_{j,t}$)} &  &  &  &  & 0.3345 & 0.0234 & 0.0215 \\
 &  &  &  &  & (0.038) & (0.042) & (0.333) \\  
$\mathbbm{1}${(Ptt$_{j,t}$)}&  &  &  &  & 0.0988 & 0.0849 & 0.0873 \\
 &  &  &  &  & (0.153) & (0.151) & (0.203) \\  
$\mathbbm{1}${(Variable 3$_{[1,5],}$ $_{j,t}$)} &  &  &  &  & 0.315 & 0.327 & 0.229 \\
 &  &  &  &  & (0.206) & (0.202) & (0.200) \\  
$\mathbbm{1}${(Variable 3$_{(5,11],}$ $_{j,t}$)} &  &  &  &  & -0.336 & 0.025 & 0.007 \\
 &  &  &  &  & (0.043) & (0.042) & (0.023) \\  
$\mathbbm{1}${(Variable 3$_{(11,20],}$ $_{j,t}$)}&  &  &  &  & -0.43** & -0.33** & -0.40** \\
 &  &  &  &  & (0.178) & (0.175) & (0.185) \\  
$\mathbbm{1}${(Variable 3$_{(20,35],}$ $_{j,t}$)}&  &  &  &  & 1.203** & 1.116** & 1.066* \\
 &  &  &  &  & (0.534) & (0.538) & (0.565) \\  
$\mathbbm{1}${(Variable 3$_{>35},$ $_{j,t}$)} &  &  &  &  & 0.020 & 0.030 & 0.003 \\
 &  &  &  &  & (0.0420) & (0.0433) & (0.0219) \\  
$\mathbbm{1}${(Age Group 1$_{j,t}$)}  &  &  &  &  & 0.291*** & 0.218** & 0.213** \\
 &  &  &  &  & (0.119) & (0.116) & (0.0846) \\  
$\mathbbm{1}${(Age Group 2$_{j,t}$)} &  &  &  &  & 0.3392 & 0.0823 & 0.0702 \\
 &  &  &  &  & (0.337) & (0.337) & (0.117) \\  
$\mathbbm{1}${(Age Group 3$_{j,t}$)} &  &  &  &  & 0.0250 & 0.0207 & 0.3379 \\
 &  &  &  &  & (0.021) & (0.021) & (0.023) \\  
$\mathbbm{1}${(Age Group 4$_{j,t}$)} &  &  &  &  & 0.0621 & -0.334 & -0.3355 \\
 &  &  &  &  & (0.120) & (0.339) & (0.121) \\  
$\mathbbm{1}${(Age Group 5$_{j,t}$)} &  &  &  &  & 0.137 & 0.355** & 0.123 \\
 &  &  &  &  & (0.160) & (0.157) & (0.166) \\  

 \hline 

\midrule
\textbf{Fixed Effects} \\     
Time &X&X&X&X&X&X&X \\    
Country &&X&X&&X&X & \\    
Time$\times$Country &&&X&&&X & \\    
Location &&&&X&&&X \\    
\midrule
Observations & 16,175 & 16,175 & 16,158 & 16,059 & 15,041 & 15,041 & 14,941 \\  
 R-squared & 0.095 & 0.144 & 0.193 & 0.353 & 0.171 & 0.205 & 0.357 \\ \hline


\end{xltabular}

\end{landscape}

\end{document}

This code works well except of that the column lengths are not the same for each column (i.e., columns 5, 6, 7 have much larger gaps in between).

8
  • 1
    For the first point, you can use the xltabular environment, from the homonymous package, which brings the functionalities of longtable to tabularx (same syntax as longtable). For the second point, it's not very bclear to me. Could you explain more?
    – Bernard
    Mar 25, 2020 at 23:32
  • Thanks @Bernard. So, changing the \begin{longtable} to \begin{xltabular} would solve the issue? Regarding the second point, in between the first row (coefficient of Not Social Distancing) and the second row, there is a larger gap than, for example, the gap that comes right after the standard error (i.e., rows 2 and 3).
    – Job
    Mar 25, 2020 at 23:41
  • @Bernard, I just tried changing the package to \begin{xltabular}, but the table still does not look correct.
    – Job
    Mar 25, 2020 at 23:42
  • 1
    Yes, it would be enough to fit the page. However, remember a tabularx environment requires at least one X column.
    – Bernard
    Mar 25, 2020 at 23:43
  • Thanks @Bernard. I just change the function to \begin{xltabular}{\textwidth}{X}, but the table does not look correct. I am not sure what exactly you mean by columns. Would you be kind to make the change and post the example? Thanks in advance..
    – Job
    Mar 25, 2020 at 23:47

1 Answer 1

3
  • very. very actual table ...
  • I would use S columns for columns 2 -- 8
  • calculation of \tabcolsep left to LaTeX
  • for table use longtable with settings \setlength\LTleft{0pt}\setlength\LTright{0pt}
  • reduce table's font size to \small:
\documentclass[final,3p,times,12pt]{elsarticle}
\usepackage{caption}
\captionsetup{font=small}
\usepackage{array}
\newcolumntype{M}[1]{>{\raggedright}m{#1}}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{bbm}
\usepackage{longtable}
\usepackage{siunitx}

\begin{document}
\begingroup
\small
\sisetup{table-format=1.4,
         table-space-text-pre=(,
         table-space-text-post=***,
         table-align-text-post=false,
         input-symbols=()
         }
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{0pt}
    \begin{longtable}{@{\extracolsep{\fill}}    M{8em}
                                           *{7}{S}}
\caption[Coronavirus rates as a logarithmic function of social distancing]
        {Coronavirus rates as a logarithmic function of social distancing\\[1ex]
        \footnotesize  
        Something something something something something something something something something something something something something something something something something something something something something something something something something something something something something. }
\label{tab:čongtable-covit-19}  \\
    \toprule
\multicolumn{1}{c}{}
    & \multicolumn{7}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\
    \cmidrule{2-8}
\multicolumn{1}{c}{}
    & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} \\
    \midrule
\endfirsthead
    \caption[]{Coronavirus rates as a logarithmic function of social distancing (cont.)} \\
    \midrule
\multicolumn{1}{c}{}
    & \multicolumn{7}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\
    \cmidrule{2-8}
\multicolumn{1}{c}{}
    & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} \\
    \midrule
\endhead
    \midrule
\multicolumn{7}{@{}r@{}}{\footnotesize\textit{continues on the next page}}
\endfoot
    \bottomrule
\endlastfoot

$\mathbbm{1}$ (Not 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)   \\
$\mathbbm{1}$ (Pnst  Type$_{j,t}$)    
    &           &           &           &           & 0.331***  & 0.331***  &           \\
    &           &           &           &           & (0.3359)  & (0.3359)  &           \\
$\mathbbm{1}$ (Long variable name$_{j,t}$)    
    &           &           &           &           & -0.3315   & -0.3313   &           \\
    &           &           &           &           & (0.3313)  & (0.3313)  &           \\
$\mathbbm{1}$ (Intense 3$_{j,t}$)     
    &           &           &           &           & 0.07**    & 0.08**    & 0.06*     \\
    &           &           &           &           & (0.000)   & (0.000)   & (0.000)   \\
$\mathbbm{1}$ (Insurance$_{j,t}$) 
    &           &           &           &           & 0.133     & 0.149     & 0.114     \\
    &           &           &           &           & (0.090)   & (0.090)   & (0.091)   \\
$\mathbbm{1}$ (Gender$_{j,t}$) 
    &           &           &           &           & 0.3***    & 0.3***    & 0.07**    \\
    &           &           &           &           & (0.021)   & (0.021)   & (0.067)   \\
$\mathbbm{1}$ (Facility P$_{j,t}$)  
    &           &           &           &           & 0.006     & 0.005     & 0.025**   \\
    &           &           &           &           & (0.008)   & (0.008)   & (0.033)   \\
$\mathbbm{1}$ (Att$_{j,t}$)  
    &           &           &           &           & 0.3345    & 0.0234    & 0.0215    \\
    &           &           &           &           & (0.038)   & (0.042)   & (0.333)   \\
$\mathbbm{1}$ (Ptt$_{j,t}$) 
    &           &           &           &           & 0.0988    & 0.0849    & 0.0873    \\
    &           &           &           &           & (0.153)   & (0.151)   & (0.203)   \\
$\mathbbm{1}$ (Variable 3$_{[1,5],}$ $_{j,t}$)  
    &           &           &           &           & 0.315     & 0.327     & 0.229     \\
    &           &           &           &           & (0.206)   & (0.202)   & (0.200)   \\
$\mathbbm{1}$ (Variable 3$_{(5,11],}$ $_{j,t}$) 
    &           &           &           &           & -0.336    & 0.025     & 0.007     \\
    &           &           &           &           & (0.043)   & (0.042)   & (0.023)   \\
$\mathbbm{1}$ (Variable 3$_{(11,20],}$ $_{j,t}$) 
    &           &           &           &           & -0.43**   & -0.33**   & -0.40**   \\
    &           &           &           &           & (0.178)   & (0.175)   & (0.185)   \\
$\mathbbm{1}$ (Variable 3$_{(20,35],}$ $_{j,t}$) 
    &           &           &           &           & 1.203**   & 1.116**   & 1.066*    \\
    &           &           &           &           & (0.534)   & (0.538)   & (0.565)   \\
$\mathbbm{1}$ (Variable 3$_{>35},$ $_{j,t}$) 
    &           &           &           &           & 0.020     & 0.030     & 0.003     \\
    &           &           &           &           & (0.0420)  & (0.0433)  & (0.0219)  \\
$\mathbbm{1}$ (Age Group 1$_{j,t}$)   
    &           &           &           &           & 0.291***  & 0.218**   & 0.213**   \\
    &           &           &           &           & (0.119)   & (0.116)   & (0.0846)  \\
$\mathbbm{1}$ (Age Group 2$_{j,t}$) 
    &           &           &           &           & 0.3392    & 0.0823    & 0.0702    \\
    &           &           &           &           & (0.337)   & (0.337)   & (0.117)   \\
$\mathbbm{1}$ (Age Group 3$_{j,t}$) 
    &           &           &           &           & 0.0250    & 0.0207    & 0.3379    \\
    &           &           &           &           & (0.021)   & (0.021)   & (0.023)   \\
$\mathbbm{1}$ (Age Group 4$_{j,t}$)  
    &           &           &           &           & 0.0621    & -0.334    & -0.3355   \\
    &           &           &           &           & (0.120)   & (0.339)   & (0.121)   \\
$\mathbbm{1}$ (Age Group 5$_{j,t}$)  
    &           &           &           &           & 0.137     & 0.355**   & 0.123     \\
    &           &           &           &           & (0.160)   & (0.157)   & (0.166)   \\
    \midrule
\textbf{Fixed Effects} \\
Time    
    & {X}       & {X}       & {X}       & {X}       & {X}       & {X}       & {X}       \\
Country 
    &           & {X}       & {X}       &           & {X}       & {X}       & {X}       \\
Time$\times$Country 
    &           &           & {X}       &           &           & {X}       &           \\
Location
    &           &           &           & {X}       &           &           & {X}       \\
\midrule
Observations    
    & {16,175}  & {16,175}  & {16,158}  & {16,059}  & {15,041}  & {15,041}  & {14,941}  \\
R-squared       
    & 0.095     & 0.144     & 0.193     & 0.353     & 0.171     & 0.205     & 0.357     \\
    \end{longtable}
\endgroup
\end{document}

enter image description here

Addendum It is not clear the meaning of $\mathbbm{1}$ before cells in the in the first column contents. I would remove them together parenthesis around cell contents. With this is obtained a bit more space for table. Also I would introduce small vertical space between each second row in the first part of table. IN the seccond part of table is consider your ask in comments below:

\documentclass[final,3p,times,12pt]{elsarticle}
\usepackage{caption}
\captionsetup{font=small}
\usepackage{booktabs, longtable}
\newcommand\mcc[1]{\multicolumn{1}{c}{#1}}
\usepackage{bbm}
\usepackage{siunitx}

\begin{document}
\begingroup
\footnotesize
\sisetup{table-format=1.4,
         table-space-text-pre=(,
         table-space-text-post=***,
         table-align-text-post=false,
         input-symbols=(),
         table-alignment=right
         }
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{0pt}
    \begin{longtable}{@{\extracolsep{\fill}} l
                                           *{7}{S}}
\caption[Coronavirus rates as a logarithmic function of social distancing]
        {Coronavirus rates as a logarithmic function of social distancing\\[1ex]
        \footnotesize  
        Something something something something something something something something something something something something something something something something something something something something something something something something something something something something something. }
\label{tab:čongtable-covit-19}  \\
    \toprule
\multicolumn{1}{c}{}
    & \multicolumn{7}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\
    \cmidrule{2-8}
\multicolumn{1}{c}{}
    & \mcc{(1)} & \mcc{(2)} & \mcc{(3)} & \mcc{(4)} & \mcc{(5)} & \mcc{(6)} & \mcc{(7)} \\
    \midrule
\endfirsthead
    \caption[]{Coronavirus rates as a logarithmic function of social distancing (cont.)} \\
    \midrule
\multicolumn{1}{c}{}
    & \multicolumn{7}{c}{Dependent Variable: $\mathbbm{1}${(Death$_{j,t}$)}} \\
    \cmidrule{2-8}
\multicolumn{1}{c}{}
    & \mcc{(1)} & \mcc{(2)} & \mcc{(3)} & \mcc{(4)} & \mcc{(5)} & \mcc{(6)} & \mcc{(7)} \\
    \midrule
\endhead
    \midrule
\multicolumn{8}{@{}r@{}}{\footnotesize\textit{continues on the next page}}
\endfoot
    \bottomrule
\endlastfoot

Not 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)   \\
    \addlinespace
Pnst  Type$_{j,t}$    
    &           &           &           &           & 0.331***  & 0.331***  &           \\
    &           &           &           &           & (0.3359)  & (0.3359)  &           \\
    \addlinespace
Long variable name$_{j,t}$    
    &           &           &           &           & -0.3315   & -0.3313   &           \\
    &           &           &           &           & (0.3313)  & (0.3313)  &           \\
    \addlinespace
Intense 3$_{j,t}$     
    &           &           &           &           & 0.07**    & 0.08**    & 0.06*     \\
    &           &           &           &           & (0.000)   & (0.000)   & (0.000)   \\
    \addlinespace
Insurance$_{j,t}$ 
    &           &           &           &           & 0.133     & 0.149     & 0.114     \\
    &           &           &           &           & (0.090)   & (0.090)   & (0.091)   \\
    \addlinespace
Gender$_{j,t}$ 
    &           &           &           &           & 0.3***    & 0.3***    & 0.07**    \\
    &           &           &           &           & (0.021)   & (0.021)   & (0.067)   \\
    \addlinespace
Facility P$_{j,t}$  
    &           &           &           &           & 0.006     & 0.005     & 0.025**   \\
    &           &           &           &           & (0.008)   & (0.008)   & (0.033)   \\
    \addlinespace
Att$_{j,t}$  
    &           &           &           &           & 0.3345    & 0.0234    & 0.0215    \\
    &           &           &           &           & (0.038)   & (0.042)   & (0.333)   \\
    \addlinespace
Ptt$_{j,t}$ 
    &           &           &           &           & 0.0988    & 0.0849    & 0.0873    \\
    &           &           &           &           & (0.153)   & (0.151)   & (0.203)   \\
    \addlinespace
Variable 3$_{[1,5]\;j,t}$  
    &           &           &           &           & 0.315     & 0.327     & 0.229     \\
    &           &           &           &           & (0.206)   & (0.202)   & (0.200)   \\
    \addlinespace
Variable 3$_{(5,11],\;j,t)}$ 
    &           &           &           &           & -0.336    & 0.025     & 0.007     \\
    &           &           &           &           & (0.043)   & (0.042)   & (0.023)   \\
    \addlinespace
Variable 3$_{(11,20],\;j,t)}$
    &           &           &           &           & -0.43**   & -0.33**   & -0.40**   \\
    &           &           &           &           & (0.178)   & (0.175)   & (0.185)   \\
    \addlinespace
Variable 3$_{(20,35],\;j,t)}$
    &           &           &           &           & 1.203**   & 1.116**   & 1.066*    \\
    &           &           &           &           & (0.534)   & (0.538)   & (0.565)   \\
    \addlinespace
Variable 3$_{>35,\;j,t}$
    &           &           &           &           & 0.020     & 0.030     & 0.003     \\
    &           &           &           &           & (0.0420)  & (0.0433)  & (0.0219)  \\
    \addlinespace
Age Group 1$_{j,t}$   
    &           &           &           &           & 0.291***  & 0.218**   & 0.213**   \\
    &           &           &           &           & (0.119)   & (0.116)   & (0.0846)  \\
    \addlinespace
Age Group 2$_{j,t}$ 
    &           &           &           &           & 0.3392    & 0.0823    & 0.0702    \\
    &           &           &           &           & (0.337)   & (0.337)   & (0.117)   \\
    \addlinespace
Age Group 3$_{j,t}$ 
    &           &           &           &           & 0.0250    & 0.0207    & 0.3379    \\
    &           &           &           &           & (0.021)   & (0.021)   & (0.023)   \\
    \addlinespace
Age Group 4$_{j,t}$  
    &           &           &           &           & 0.0621    & -0.334    & -0.3355   \\
    &           &           &           &           & (0.120)   & (0.339)   & (0.121)   \\
    \addlinespace
Age Group 5$_{j,t}$  
    &           &           &           &           & 0.137     & 0.355**   & 0.123     \\
    &           &           &           &           & (0.160)   & (0.157)   & (0.166)   \\
    \midrule
\textbf{Fixed Effects} \\
Time    
    & {X}       & {X}       & {X}       & {X}       & {X}       & {X}       & {X}       \\
Country 
    &           & {X}       & {X}       &           & {X}       & {X}       & {X}       \\
Time$\times$Country 
    &           &           & {X}       &           &           & {X}       &           \\
Location
    &           &           &           & {X}       &           &           & {X}       \\
\midrule
Observations    
    & {16,175}  & {16,175}  & {16,158}  & {16,059}  & {15,041}  & {15,041}  & {14,941}  \\
R-squared       
    & {0.095}     & {0.144} & {0.193}   & {0.353}   & {0.171}   & {0.205}   & {0.357}   \\
    \end{longtable}
\endgroup
\end{document}

enter image description here

Edit:

  • S columns are defined insiunitx package. They are use for align numbers at decimal points.
  • In settings are define features of S solumns as follows:
    • Size of numbers with tabular-format=<num. of inteders>.>num of decimal digits.
    • Additional space before numbers with table-space-text-pre=(.
    • Additional space after numbers with table-space-text-pre=***.
    • Align back parenthesize and * after number with table-align-text-post=false.
    • Input symbols, whic are consider with numbers formation (), ), which are used in tables) with input-symbols=()
    • for right align text in S columns serve table-alignment=right (according to my test, I would omit this option and use default setting, which is center. In this case you ca alo delete definition of \mcc command as well its use in table headers, as is done in the first example).
  • To have cells' contents in the first column, you just replace M column withl, but with this you need to reduce column size, that table can be fit in text width.
13
  • That looks awesome. Many thanks, @Zarko. One quick question. Is there any way to align the numbers following R-squared so that they are right below the numbers of the above row?
    – Job
    Mar 26, 2020 at 0:29
  • 1
    @Job. yes, it is possible. See addendum to answer, where beside this your wish I also add some more tweaks to table design.
    – Zarko
    Mar 26, 2020 at 0:40
  • Awesome, thanks @Zarko. One similar issue, the X's right after "Time" are somehow in between "Fixed Effects" and "Time". I added another `\`, but that comments seems to be ignored.
    – Job
    Mar 26, 2020 at 0:42
  • 1
    @Job, it is already corrected. I forgot on it when writing addendum :-(. No, now is table as should be. cell's content in curly braces is aligned right (as you desired, however, i would rather left them centered in cells, as is usual done in such tables) other numbers ar aligned at decimal points.
    – Zarko
    Mar 26, 2020 at 0:59
  • 1
    @Job, thank you very much, see edited answer.
    – Zarko
    Mar 26, 2020 at 1:21

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.