0

using a recent suggestion from @zarko with talltblr, now my desired table is with one model ( one column for each headers)

doing some modification, the new table still exceeds margins. Here are the code and output

\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 = {Contagion effects on Asia Region },
 label = {tab17},
note{} = {Standard errors in parentheses:\newline
   *:    $p<0.10$,\quad
   **:   $p<0.05$,\quad
   ***:  $p<0.01$.},
       ]{rowhead = 1,
         colsep = 2pt,
         colspec = {@{}  Q[l,h, font=\scshape]
                    *{4}{X[c, m, si]}
                    @{}},
         row{1,2} = {guard, font=\small\bfseries},
         row{1}   = {abovesep = 2pt},
         row{3-Z} = {rowsep = -1pt},
         row{Y}   = {guard, mode=text},
         row{odd[3]} = {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}
   
     % \cmidrule[lr]{1-2}
 % \cmidrule[lr]{3-4}
 % \cmidrule[lr]{5-6}
%%%%
  &     Model (1)
      % &   Model (2)
           &   Model (1)
       %        &   Model (2)
                   &   Model (1)
        %               &   Model (2)
                           \\
     \midrule
%%%%
\subtitle   Pull Factors
   &               &               &               &           &               &           \\
   &               &               &               &           &               &           \\
%%%%%
%\midrule
       
GDP per capita 
&   0.021   &    0.033\tc{**}   &    -0.014 \\
&   (0.014) &    (0.013)            &  (0.010) \\

Real interest rate  
&0.007    &0.005  &   0.004  \\
&(0.005)  &(0.005)&     (0.004) \\  

Inflation    
&-0.005      &  0.001 &     -0.005  \\
&   (0.005)   & (0.004)&         (0.004)\\

Trade Openness  
&-0.073\tc{***}       &     0.002  &        -0.062\tc{**}   \\
&   (0.021)        &    (0.021)    &        (0.020)         \\

Exchange regime 
&0.021      &       -0.009        &     0.028\tc{*}      \\
&    (0.014)    &      (0.014)        &         (0.015)          \\

Peg 
&0.083\tc{***} &        0.024\tc{**}&       0.066\tc{***}    \\
&(0.010)         &      (0.011)   &(0.012)               \\


Mean restrictions KA    
&  0.403*** &       0.433\tc{**}       &    -0.024  \\
&   (0.182)     &    (0.185)            &(0.105)    \\


Trade link  
&0.061\tc{***}  &   -0.009        &0.064\tc{***} \\
&   (0.017)       &         (0.017)   & (0.016)            \\

GEODIS   
& -0.006 &        -0.016&       0.001    \\
&   (0.018)&    (0.014) &    (0.013)    \\


DHL
&   0.686***    &   0.432\tc{**}&       0.293\tc{**}    \\
&   (0.176)     &(0.182)         &           (0.126)        \\
                       
%%%%
\subtitle   Push Factors
   &                             &                        &                          \\
   &                             &                          &                         \\
%%%%%                                                       
                   
Global liquidity    

&-0.017\tc{***}         &-0.024\tc{***}         &   0.007\tc{**}      \\
&   (0.004)               & (0.004)                   &(0.014)          \\

Fed monetary policy stance 

&   0.001   &    0.003     &          -0.003    \\
&    (0.003)&       (0.003) &       (0.003)       \\

Shadow Rate 

&-0.008\tc{***}&        -0.011\tc{***} & 0.002   \\
&   (0.002)      &  (0.002)             &    (0.002)       \\


Constant    
&0.082   &  -0.209  &   0.24\tc{5***}   \\
&   (0.117)&         (0.133)&        (0.076)    \\

\bottomrule 
Country FE  
&   Y    & Y &      Y \\
Year FE 
&   N        & N &     N  \\    
Observations    
&79         &   79      &   79    \\
R-squared   
&0.675   &  0.502     & 0.595      \\
  \bottomrule
\end{talltblr}
 \end{table}  % <---
\end{document}

output :

enter image description here

Now using modification to original proposition of @zarko, i'm starting to get close to the desired table; but the texniccenter shows several times: missing number treated as zero :

\documentclass{article}
\usepackage[margin=2cm,a4paper]{geometry} % set page parameters suitably
%---------------- show page layout. don't use in a real document!
%\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\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=1, c=6]{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}[ht]
\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 = {Contagion effects on Asia Region },
label = {tab17},
note{} = {Standard errors in parentheses:\newline
  *:    $p<0.10$,\quad
  **:   $p<0.05$,\quad
  ***:  $p<0.01$.},
      ]{rowhead = 1,
        colsep = 1pt,
        colspec = {@{}  Q[l,h, font=\scshape]
                   *{3}{X[c, m, si]}
                   @{}},
        row{1,2} = {guard, font=\small\bfseries},
        row{1}   = {abovesep = 1pt},
        row{3-Z} = {rowsep = -1pt},
        row{Y}   = {guard, mode=text},
        row{odd[4]} = {abovesep=1ex},
          }
  \toprule
  &   \SetCell[c=1]{c} {Capital flows\\ Eq. 1}
      &    \SetCell[c=1]{c} {Capital inflows\\ Eq. 2}
              &     \SetCell[c=1]{c} {Capital outflows\\ Eq. 3}
                     % &   
                                           \\
  % \cmidrule[lr]{2-3}
  % \cmidrule[lr]{4-5}
  % \cmidrule[lr]{6-7}
       
       \cmidrule[lr]{1-2}
   \cmidrule[lr]{3-4}
   \cmidrule[lr]{5-6}
       
%%%%
   &   Model (1)

           &   Model (2)
        
                   &   Model (3)
            
                          \\
    \midrule
%%%%
\subtitle   Pull Factors
   &   &   &     \\
   &   &   &      \\
%%%%%
GDP per capita
   & 0.021         & 0.033\tc{**}  & -0.014                 \\
   & (0.014)       & (0.013)       & (0.010)                \\
Real interest rate
   & 0.007         & 0.005         & 0.004                    \\
   & (0.005)       & (0.005)       & (0.004)                \\
Inflation
   &-0.005         &  0.001        & -0.005                  \\
   &   (0.005)     & (0.004)       & (0.004)                \\
Trade Openness
   &-0.073\tc{***} & 0.002         & -0.062\tc{**}            \\
   &   (0.021)     & (0.021)       & (0.020)                 \\

Exchange regime
   &0.021          & -0.009        & 0.028\tc{*}             \\
   &    (0.014)    & 0.014)        & (0.015)                  \\

Peg
   &0.083\tc{***}  & 0.024\tc{**}  & 0.066\tc{***}           \\
   &(0.010)        & (0.011)       & (0.012)                  \\
Mean restrictions KA
   &  0.403***     & 0.433\tc{**}  & -0.024                  \\
   &   (0.182)     & (0.185)       & (0.105)                 \\
Trade link
   &0.061\tc{***}  & -0.009        & 0.064\tc{***}           \\
   &   (0.017)     & (0.017)       & (0.016)                 \\
GEODIS
   & -0.006        & -0.016        & 0.001                 \\
   & (0.018)       & (0.014)       & (0.013)                \\
DHL
   & 0.686***      & 0.432\tc{**}  & 0.293\tc{**}            \\
   & (0.176)       & (0.182)       & (0.126)                  \\
%%%%
\subtitle   Pull Factors
   &   &   &    \\
   &   &   &    \\
%%%%%
Global liquidity
   &-0.017\tc{***} &-0.024\tc{***} & 0.007\tc{**}            \\
   & (0.004)       & (0.004)       & (0.014)                 \\
Fed monetary policy stance
   & 0.001         & 0.003         & -0.003                   \\
   & (0.003)       & (0.003)       & (0.003)                 \\
Shadow Rate
   &-0.008\tc{***} &-0.011\tc{***} & 0.002                   \\
   & (0.002)       & (0.002)       & (0.002)                \\
Constant
   & 0.082         & -0.209        & 0.24\tc{5***}           \\
   & (0.117)       & (0.133)       & (0.076)                 \\
   \midrule[\heavyrulewidth]
Country FE
   & Y             & Y             & Y                        \\
Year FE
   &   N           & N             & N                       \\
Observations
   & 79            & 79            & 79                      \\
R-squared
   & 0.675         &  0.502        & 0.595                   \\
   \bottomrule
\end{talltblr}
\end{table} 
\end{document}

output :

enter image description here

6
  • Sorry, your question is not entirely clear. How many columns has your table? if it has 1+ 6, than please provide contents last three columns (at list for few first table rows).
    – Zarko
    May 16, 2023 at 14:23
  • @zarko , Thanks for replying to my question, you are used to saving my life ;) .. actually, I need THREE columns in the table, I did not understand how to manage \cmidrule.. the table must show in column 1: Capital flows; column 2: Capital inflows; column 3: Capital outflows
    – HAITHEM
    May 16, 2023 at 14:43
  • Please show us what you after. Some sketch will be very helpful. In the case, that "capital outflows" is superfluous, than simple remove it from MWE. IN answer I assume that it should be present. If not, than, than tell us, how many columns span "Capital inflows".
    – Zarko
    May 16, 2023 at 15:05
  • @zarko see edit to my anwser, it is close to desired table
    – HAITHEM
    May 16, 2023 at 15:16
  • @zarko capital inflows should correspond to model 2 and capital outflows to model 3
    – HAITHEM
    May 16, 2023 at 15:32

1 Answer 1

2
  • assuming that you like to have three pairs of "Capital flows" columns, i.e. altogether six columns in them
  • you have errors in column specifications. It should be:
         colspec = {@{}  Q[l,h, font=\scshape]
                    *{6}{X[c, m, si]}   % observe 6
                    @{}},
  • each rows had to haw inserted all ampersands. Skip some of them is prohibited
  • Correct MWE can (should) be:
\documentclass{article}
\usepackage[margin=2cm,a4paper]{geometry} % set page parameters suitably
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\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}[ht]
\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 = {Contagion effects on Asia Region },
 label = {tab17},
note{} = {Standard errors in parentheses:\newline
   *:    $p<0.10$,\quad
   **:   $p<0.05$,\quad
   ***:  $p<0.01$.},
       ]{rowhead = 1,
         colsep = 2pt,
         colspec = {@{}  Q[l,h, font=\scshape]
                    *{6}{X[c, m, si]}
                    @{}},
         row{1,2} = {guard, font=\small\bfseries},
         row{1}   = {abovesep = 2pt},
         row{3-Z} = {rowsep = -1pt},
         row{Y}   = {guard, mode=text},
         row{odd[4]} = {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
%%%%
\subtitle   Pull Factors
    &   &   &   &   &   &   \\
    &   &   &   &   &   &   \\
%%%%%
GDP per capita
    & 0.021         & 0.033\tc{**}  & -0.014        &           &               &           \\
    & (0.014)       & (0.013)       & (0.010)       &           &               &           \\
Real interest rate
    & 0.007         & 0.005         & 0.004         &           &               &           \\
    & (0.005)       & (0.005)       & (0.004)       &           &               &           \\
Inflation
    &-0.005         &  0.001        & -0.005        &           &               &           \\
    &   (0.005)     & (0.004)       & (0.004)       &           &               &           \\
Trade Openness
    &-0.073\tc{***} & 0.002         & -0.062\tc{**} &           &               &           \\
    &   (0.021)     & (0.021)       & (0.020)       &           &               &           \\

Exchange regime
    &0.021          & -0.009        & 0.028\tc{*}   &           &               &           \\
    &    (0.014)    & 0.014)        & (0.015)       &           &               &           \\

Peg
    &0.083\tc{***}  & 0.024\tc{**}  & 0.066\tc{***} &           &               &           \\
    &(0.010)        & (0.011)       & (0.012)       &           &               &           \\
Mean restrictions KA
    &  0.403***     & 0.433\tc{**}  & -0.024        &           &               &           \\
    &   (0.182)     & (0.185)       & (0.105)       &           &               &           \\
Trade link
    &0.061\tc{***}  & -0.009        & 0.064\tc{***} &           &               &           \\
    &   (0.017)     & (0.017)       & (0.016)       &           &               &           \\
GEODIS
    & -0.006        & -0.016        & 0.001         &           &               &           \\
    & (0.018)       & (0.014)       & (0.013)       &           &               &           \\
DHL
    & 0.686***      & 0.432\tc{**}  & 0.293\tc{**}  &           &               &           \\
    & (0.176)       & (0.182)       & (0.126)       &           &               &           \\
%%%%
\subtitle   Pull Factors
    &   &   &   &   &   &   \\
    &   &   &   &   &   &   \\
%%%%%
Global liquidity
    &-0.017\tc{***} &-0.024\tc{***} & 0.007\tc{**}  &           &               &           \\
    & (0.004)       & (0.004)       & (0.014)       &           &               &           \\
Fed monetary policy stance
    & 0.001         & 0.003         & -0.003        &           &               &           \\
    & (0.003)       & (0.003)       & (0.003)       &           &               &           \\
Shadow Rate
    &-0.008\tc{***} &-0.011\tc{***} & 0.002         &           &               &           \\
    & (0.002)       & (0.002)       & (0.002)       &           &               &           \\
Constant
    & 0.082         & -0.209        & 0.24\tc{5***} &           &               &           \\
    & (0.117)       & (0.133)       & (0.076)       &           &               &           \\
    \midrule[\heavyrulewidth]
Country FE
    & Y             & Y             & Y             &           &               &           \\
Year FE
    &   N           & N             & N             &           &               &           \\
Observations
    & 79            & 79            & 79            &           &               &           \\
R-squared
    & 0.675         &  0.502        & 0.595         &           &               &           \\
    \bottomrule
\end{talltblr}
 \end{table} 
\end{document}

enter image description here

Addendum:

  • I'm still not sure what you after.
  • From your comments I guessing that actually you like to have table with 1 + 3 columns as follows:

enter image description here

  • MWE, in which are
    • removed all multi column cells in table body,
    • corrected \subtitle command which now span four columns,
    • In table preamble are defined only four columns,
    • X column type is replaced by Q, consequently table is narower,
    • Improved vertical spacing around cells contents:
\documentclass{article}
\usepackage[margin=2cm,a4paper]{geometry} % set page parameters suitably
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\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=4]{c, bg=gray!30,               % changed from 7 to 4
                  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}[ht]
\small
\sisetup{
input-open-uncertainty =,
input-close-uncertainty=,
table-align-text-after=false,
table-align-text-before=false,
table-format={(}-1.3{$^{***}$}
}
\centering
\begin{talltblr}[
caption = {Contagion effects on Asia Region },
 label = {tab17},
note{} = {Standard errors in parentheses:\newline
   *:    $p<0.10$,\quad
   **:   $p<0.05$,\quad
   ***:  $p<0.01$.},
                ]{
            colspec = {@{}  Q[l,h, font=\scshape]
                       *{3}{Q[c, m, si]}
                       @{}},
         row{1,2} = {guard, font=\small\bfseries},
         row{1}   = {abovesep = 2pt},
         row{3-Z} = {rowsep = -1pt},
         row{V}   = {guard, belowsep=2pt},
         row{W}   = {guard, abovesep=2pt},
         row{Y}   = {guard},
         row{odd[2-U]} = {abovesep=1ex},
                }
   \toprule
   &   {Capital flows\\ Eq. 1}
        &   {Capital inflows\\ Eq. 2}
            &   {Capital outflows\\ Eq. 3}
                           \\
    \cmidrule[lr]{2-2}
    \cmidrule[lr]{3-3}
    \cmidrule[lr]{4-4}
%%%%
    &   Model (1)
        &   Model (2)
            &   Model (3)
                           \\
     \midrule
%%%%
\subtitle   Pull Factors
    &   &   &               \\
    &   &   &               \\
%%%%%
GDP per capita
    & 0.021         & 0.033\tc{**}  & -0.014        \\
    & (0.014)       & (0.013)       & (0.010)       \\
Real interest rate
    & 0.007         & 0.005         & 0.004         \\
    & (0.005)       & (0.005)       & (0.004)       \\
Inflation
    &-0.005         &  0.001        & -0.005        \\
    &   (0.005)     & (0.004)       & (0.004)       \\
Trade Openness
    &-0.073\tc{***} & 0.002         & -0.062\tc{**} \\
    & (0.021)       & (0.021)       & (0.020)       \\
Exchange regime
    & 0.021         & -0.009        & 0.028\tc{*}   \\
    & (0.014)       & 0.014)        & (0.015)       \\
Peg
    & 0.083\tc{***} & 0.024\tc{**}  & 0.066\tc{***} \\
    & (0.010)       & (0.011)       & (0.012)       \\
Mean restrictions KA
    & 0.403***      & 0.433\tc{**}  & -0.024        \\
    & (0.182)       & (0.185)       & (0.105)       \\
Trade link
    & 0.061\tc{***} & -0.009        & 0.064\tc{***} \\
    & (0.017)       & (0.017)       & (0.016)       \\
GEODIS
    & -0.006        & -0.016        & 0.001         \\
    & (0.018)       & (0.014)       & (0.013)       \\
DHL
    & 0.686***      & 0.432\tc{**}  & 0.293\tc{**}  \\
    & (0.176)       & (0.182)       & (0.126)       \\
%%%%
\subtitle   Pull Factors
    &   &   &               \\
    &   &   &               \\
%%%%%
Global liquidity
    &-0.017\tc{***} &-0.024\tc{***} & 0.007\tc{**}  \\
    & (0.004)       & (0.004)       & (0.014)       \\
Fed monetary policy stance
    & 0.001         & 0.003         & -0.003        \\
    & (0.003)       & (0.003)       & (0.003)       \\
Shadow Rate
    &-0.008\tc{***} &-0.011\tc{***} & 0.002         \\
    & (0.002)       & (0.002)       & (0.002)       \\
Constant
    & 0.082         & -0.209        & 0.24\tc{5***} \\
    & (0.117)       & (0.133)       & (0.076)       \\
    \midrule[\heavyrulewidth]
Country FE
    & Y             & Y             & Y             \\
Year FE
    &   N           & N             & N             \\
Observations
    & 79            & 79            & 79            \\
R-squared
    & 0.675         &  0.502        & 0.595         \\
    \bottomrule
\end{talltblr}
 \end{table}
\end{document}
2
  • My thanks and appreciation, this is what i'm looking for
    – HAITHEM
    May 16, 2023 at 18:28
  • @user169906, you are welcome. Now I observe that for second table I was inserted image of the first table. I correct this now.
    – Zarko
    May 16, 2023 at 18:34

You must log in to answer this question.

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