2

using a recent suggestion from @zarko, i am encountering a problem with my new landscape table,

I have two issues. first, I want the column headers centered , (see screeshot )

second every time i add lines at the bottom of tables to describe the model ( year and country fixed effects) by YES or No , the latex shows me an error.

see my code, output, and desired table style

code:

  \documentclass{article}
  \usepackage[margin=2cm,a4paper]{geometry} % set page parameters suitably
   \usepackage{natbib}
   \usepackage[latin1]{inputenc}
   \usepackage[utf8]{inputenc}
   \usepackage{enumerate}
   \usepackage{enumitem}                    
   \usepackage[T1]{fontenc}
    \usepackage{pdflscape}
   \usepackage{tabularx}
   \usepackage{tabularx}
   \usepackage{newpxtext,newpxmath}
   \usepackage[english]{babel}
   \usepackage{xcolor}
   \newcommand\tc[1]{\textcolor{blue}{#1}}
   \usepackage[font={bf},skip=0.333\baselineskip]{caption} 
   \usepackage{subcaption}
   \usepackage{longtable}
   \usepackage{threeparttable}  
   \usepackage{booktabs}
   \usepackage{rotating}

  %----------------------------------------------------------------------------------------

   \usepackage[USenglish]{babel}

   \usepackage{microtype}
   \usepackage[hang, font=small, 
        labelfont=bf,textfont=it]{caption}
    \usepackage{tabularray}
    \UseTblrLibrary{booktabs, siunitx}
     \NewTableCommand\SCR{\SetCell[r=2]{font=\footnotesize\linespread{0.84}\selectfont}}
      \sisetup{
        input-open-uncertainty =,
    input-close-uncertainty=,
    table-align-text-after=false,
    table-align-text-before=false
        }
  \ExplSyntaxOn
\NewChildSelector{eachtwo}
  {
    \int_step_inline:nnnn {5}{2}{\l_tblr_childs_total_tl}
      { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
  }
\ExplSyntaxOff


 \begin{document}
  \begin{landscape}%\label{tab:tab2} you can not label landscape environment!
  \small
\sisetup{
input-open-uncertainty =,
 input-close-uncertainty=,
 table-align-text-after=false,
 table-align-text-before=false,
 table-format={(}-1.3{**}
  }

\begin{longtblr}[
caption = {Main effects on Asia Region},
    label = {tab:tab1},
    note{} = {Standard errors in parentheses:\newline
        *:    $p<0.10$,\quad
        **:   $p<0.05$,\quad
        ***:  $p<0.01$.},
            ]{
     rowhead = 2,
   colsep = 2pt,
  colspec = {@{} X[l,h, font=\scshape\linespread{0.84}\selectfont]
           *{6}{S}
           @{}},
row{1} = {font=\small\bfseries},
row{4-Z} = {rowsep = 0pt},
row{eachtwo} = {abovesep=1ex},
                }
\toprule              
&{{{(1)}}}  &{{{(2)}}}  &{{{(3)}}}  &{{{(4)}}}  &{{{(5)}}}  &{{{(6)}}}   \\
\midrule
 %%%%
  \SetCell[c=10]{c, font=\itshape, bg=gray8}    Pull Factors
&           &           &           &           &   
&           &           &           &           \\
   %%%%
    \midrule

   GDP per capita                     &0.011   &    -0.029 &    &0.020\tc{**}&  0.013      & 
  &-0.003      &  -0.023 & \\
                               & (0.008)&   (0.023)&  & (0.009)    &    (0.017)  & &    (0.006)  &  (0.017)& \\                
\SetCell[r=2]{l}                                                                                                                                        
  Real interest rate                 &0.012\tc{***}  &0.008\tc{*} &  &0.003    &    0.003   & &     0.009\tc{**} &  0.003 &\\
                               &(0.005)        &(0.004)     &    &(0.004) & (0.004)   & &   (0.004) &   (0.003) &\\                                                                                                                                                                 

\SetCell[r=2]{l} 
Inflation                          &0.006      &0.002    &&0.003  &     0.004 &&      0.002&-0.001& \\
                               & (0.004) &(0.004)&&(0.003)&  (0.003)&&  (0.003)&(0.003)&    \\
 \SetCell[r=2]{l}                                                                                                                                                                       
Trade Openness                    & 0.006   & -0.039   & &  0.002       &        0.002   &&       0.007 &      -0.051& \\
                              & (0.006) & (0.031)& &     (0.005)  &       (0.023)    &&      (0.007)&        (0.032)& \\

    \SetCell[r=2]{l}
   Capital flow restrictions KA & 0.057\tc{**}   &   -0.021      & &    &       &&          &     & \\
                         & (0.031)       &    (0.067)    & &    &       &&          &    & \\

     \SetCell[r=2]{l}
    Capital inflow restrictions Kai    &        &      & & 0.099\tc{**} & 0.054   &       &&        &    \\
                               &      &      & &  (0.042)     & (0.045) &       &&          &    
      \\
      \SetCell[r=2]{l}
     Capital outflow restrictions Kao    &      &      & &  & && -0.006     &  -0.065  & \\
                                &     &      & &  & &&  (0.015) &    (0.048) & \\       
                                                                                                                                                                                                                                                                                                                                                                                                 
 \SetCell[r=2]{l}                                   
 Exchange regime    & 0.001   & -0.008    &  &    -0.009   &    -0.005    & &0.005   &  -0.004 &\\
                & (0.012) & (0.013)   &  &     (0.011) &      (0.013) & &(0.015) &   (0.012) &\\
                                                            
  \SetCell[r=2]{l}
 Peg   &0.055\tc{***}&  0.015 &  &0.025\tc{***}&      0.020\tc{**}& & (0.010)&  0.036\tc{***}&\\ 
   &(0.009)      & (0.011)&  &(0.007)      &        (0.009)       & &(0.006) &   -0.001     &       
 \\
  %%%%
     \SetCell[c=10]{c, font=\itshape, bg=gray8}    Push Factors
&           &           &           &           &   
&           &           &           &           \\
   %%%%
     \midrule
    %%%%%
       \SetCell[r=2]{l} 
         Global liquidity & -0.017\tc{***}&     -0.009\tc{**}&& -0.019\tc{***}  &   -0.017\tc{***}&&    0.000 &   0.002 &\\
             &(0.003)           &(0.004)           &&(0.003)            &(0.004)          &&(0.003) &    (0.004)&  \\
                                                                                                                                                                    
        \SetCell[r=2]{l} 
     Fed monetary policy stance  &-0.003  &     -0.007\tc{**} & &   -0.001  &   -0.001   & &    -0.002 &    -0.005\\ 
                         &(0.003)    &(0.003)           &&(0.002)     &(0.002)   & &(0.003)  & (0.003)\\ 

        \SetCell[r=2]{l} 
      Shadow Rate                &-0.008\tc{***}     &-0.003 & &    -0.007\tc{***} &    -0.007\tc{***}  & & -0.001 &    0.001\\ 
                        &(0.002)      &(0.002) & &  (0.001)        &(0.002)        & &(0.001)    & (0.002)\\

          \hline
      Observations     &    104 & 104  & &  104 &   104  &  &104   &    104&\\
       Pseudo \(R^{2}\) &0.52 & 0.591& &0.470 & 0.510&  &0.326 &    0.514&\\
       \bottomrule
       \end{longtblr}
        \end{landscape}

        \end{document}

output:

enter image description here

desired headers :

enter image description here

desired bottom lines:

enter image description here

1 Answer 1

2

Like this?

enter image description here

  • your table body content is not close to desired column headers: you show seven column headers, body has ten columns ...
  • transcripting table body make table much narrower, so it can be in portrait format

Edit:
MWE, with improved distances between table rows:

\documentclass{article}
\usepackage[margin=2cm,a4paper]{geometry} % set page parameters suitably
\usepackage[T1]{fontenc}
\usepackage{newpxtext,newpxmath}
\usepackage[USenglish]{babel}

\usepackage{natbib}
\usepackage{pdflscape}
\usepackage{xcolor}
\newcommand\tc[1]{\textcolor{blue}{#1}}
%----------------------------------------------------------------------------------------
\usepackage{microtype}
\usepackage[hang, 
            font=small,
            labelfont=bf, textfont=it]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\NewTableCommand\subtitle{%
\SetCell[r=2, c=7]{c, bg=gray!30,
                   font=\bfseries\itshape,
                   cmd=\rule[-1.5ex]{0pt}{3ex}
                   }
                            }
  \sisetup{
    input-open-uncertainty =,
input-close-uncertainty=,
table-align-text-after=false,
table-align-text-before=false
    }

\begin{document}
%\begin{landscape}
\small
\sisetup{
input-open-uncertainty =,
input-close-uncertainty=,
table-align-text-after=false,
table-align-text-before=false,
table-format={(}-1.3{$^{***}$}
}

\begin{longtblr}[
caption = {Main effects on Asia Region},
  label = {tab:tab1},
note{} = {Standard errors in parentheses:\newline
    *:    $p<0.10$,\quad
    **:   $p<0.05$,\quad
    ***:  $p<0.01$.},
        ]{rowhead = 2,
          colsep = 2pt,
          colspec = {@{}  Q[l,h, font=\scshape]
                     *{6}{X[c, m, si]}
                     @{}},
          row{1,2} = {guard, font=\small\bfseries},
          row{3-V} = {rowsep = -1pt},
          row{3}   = {abovesep = 2pt},
          row{V}   = {belowsep=1pt},
          row{W-Y} = {guard, mode=text},
          row{odd[5-V]} = {abovesep=1ex},
            }
    \toprule
    &   \SetCell[c=2]{c} {Capital flows\\ Eq. 1} 
        &   &   \SetCell[c=2]{c} {Capital inflows\\ Eq. 2} 
                &   &   \SetCell[c=2]{c} {Capital outflows\\ Eq. 3}
                        &   \\
    \cmidrule[lr]{2-3}
    \cmidrule[lr]{4-5}
    \cmidrule[lr]{6-7}
%%%%
   &     model (1)
        &   model (2)
            &   model (1)
                &   model (2)
                    &   model (1)
                        &   model (2)
                            \\
    \midrule
GDP per capita
    &  0.011        & -0.029        & 0.020\tc{**}  & 0.013     & -0.003        &  -0.023   \\
    & (0.008)       & (0.023)       & (0.009)       & (0.017)   & (0.006)       & (0.017)   \\
Real interest rate                 
    &0.012\tc{***}  & 0.008\tc{*}   &  0.003        &  0.003    &  0.009\tc{**} &  0.003    \\
    &(0.005)        & (0.004)       & (0.004)       & (0.004)   & (0.004)       & (0.003)   \\
Inflation                          
    & 0.006         & 0.002         & 0.003         &  0.004    &  0.002        & -0.001    \\
    & (0.004)       & (0.004)       & (0.003)       & (0.003)   & (0.003)       & (0.003)   \\
Trade Openness                    
    & 0.006         & -0.039        &  0.002        &  0.002    &  0.007        & -0.051    \\
    & (0.006)       & (0.031)       & (0.005)       & (0.023)   & (0.007)       & (0.032)   \\
Capital flow restrictions KA 
    & 0.057\tc{**}  & -0.021        &               &           &               &           \\
    & (0.031)       & (0.067)       &               &           &               &           \\
Capital inflow restrictions Kai    
    &               &               & 0.099\tc{**}  & 0.054     &               &           \\
    &               &               & (0.042)       & (0.045)   &               &           \\
Capital outflow restrictions Kao    
    &               &               &               &           & -0.006        &  -0.065   \\
    &               &               &               &           &  (0.015)      & (0.048)   \\
Exchange regime    
    & 0.001         & -0.008        & -0.009        & -0.005    & 0.005         & -0.004    \\
    & (0.012)       & (0.013)       & (0.011)       & (0.013)   &(0.015)        & (0.012)   \\
Peg &0.055\tc{***}  &  0.015        &0.025\tc{***}  &  0.020\tc{**}
                                                                & (0.010)       & 0.036\tc{***}     \\
    &(0.009)        & (0.011)       &(0.007)        & (0.009)   & (0.006)       & -0.001    \\
%%%%
\subtitle   Push Factors
    &               &               &               &           &               &           \\
    &               &               &               &           &               &           \\
%%%%%
Global liquidity 
    & -0.017\tc{***}    & -0.009\tc{**} & -0.019\tc{***}    &   -0.017\tc{***}  &  0.000    &  0.002    \\
    & (0.003)           &(0.004)        & (0.003)           & (0.004)           & (0.003)   & (0.004)   \\

Fed monetary policy stance  
    & -0.003            & -0.007\tc{**} & -0.001            & -0.001            &    -0.002 & -0.005    \\
    & (0.003)           & (0.003)       & (0.002)           & (0.002)           & (0.003)   & (0.003)   \\
Shadow Rate                
    & -0.008\tc{***}    & -0.003        & -0.007\tc{***}    & -0.007\tc{***}    & -0.001    & 0.001     \\
    & (0.002)           & (0.002)       & (0.001)           &(0.002)            & (0.001)   & (0.002)   \\
      \midrule
Country FE
    &   Yes             &   Yes         &   Yes             &   Yes             &   Yes     &   Yes     \\
Yeare
    &   No              &   No          &   No              &   Yes             &   No      &   Yes     \\
Observations     
    & 104               & 104           &  104              &   104             &  104      &  104      \\
Pseudo \(R^{2}\) 
    & 0.52              & 0.591         & 0.470             & 0.510             &  0.326    &  0.514    \\
   \bottomrule
\end{longtblr}
%    \end{landscape}
\end{document}

Note
If table is not longer, i.e. that it can be fit on one page, you may consider to replace longtblr with talltblr and then insert it in the table float:

\documentclass{article}
\usepackage[margin=2cm,a4paper]{geometry} % set page parameters suitably
\usepackage[T1]{fontenc}
\usepackage{newpxtext,newpxmath}
\usepackage[USenglish]{babel}

\usepackage{natbib}
\usepackage{pdflscape}
\usepackage{xcolor}
\newcommand\tc[1]{\textcolor{blue}{#1}}
%----------------------------------------------------------------------------------------
\usepackage{microtype}
\usepackage[hang, 
            font=small,
            labelfont=bf, textfont=it]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\NewTableCommand\subtitle{%
\SetCell[r=2, c=7]{c, bg=gray!30,
                   font=\bfseries\itshape,
                   cmd=\rule[-1.5ex]{0pt}{3ex}
                   }
                            }
\sisetup{input-open-uncertainty =,
         input-close-uncertainty=,
         table-align-text-after=false,
         table-align-text-before=false
        }

\begin{document}
    \begin{table}
\small
\sisetup{
input-open-uncertainty =,
input-close-uncertainty=,
table-align-text-after=false,
table-align-text-before=false,
table-format={(}-1.3{$^{***}$}
}

\begin{talltblr}[
caption = {Main effects on Asia Region},
  label = {tab:tab1},
note{} = {Standard errors in parentheses:\newline
    *:    $p<0.10$,\quad
    **:   $p<0.05$,\quad
    ***:  $p<0.01$.},
        ]{rowhead = 2,
          colsep = 2pt,
          colspec = {@{}  Q[l,h, font=\scshape]
                     *{6}{X[c, m, si]}
                     @{}},
          row{1,2} = {guard, font=\small\bfseries},
          row{3-V} = {rowsep = -1pt},
          row{3}   = {abovesep=2pt},
          row{V}   = {belowsep=1pt},
          row{W-Y} = {guard, mode=text, rowsep=1pt},
          row{odd[5-V]} = {abovesep=1ex},
            }
%
%   table body is the same as before
%
\end{talltblr}   % <---
    \end{table}  % <---
\end{document}
5
  • Thanks for this professional suggestion. this is what I was looking for in the headers, meanwhile, trying to include: Country FE & Yes & Yes & Yes & Yes & Yes& Yes \\ at the bottom of table doesn't work
    – HAITHEM
    Commented Apr 18, 2023 at 9:40
  • @user169906, now added, but this should not be a problem :-)
    – Zarko
    Commented Apr 18, 2023 at 9:41
  • thanks a lot ! great job
    – HAITHEM
    Commented Apr 18, 2023 at 9:42
  • @user169906, and again just now, I make some small improvements of table design ...
    – Zarko
    Commented Apr 18, 2023 at 9:44
  • thanks, I appreciate your guidance. I'm well satisfied with both answers,
    – HAITHEM
    Commented Apr 19, 2023 at 2:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .