横向居中标题表

横向居中标题表

使用@zarko 最近的建议,我在使用新的景观表时遇到了一个问题,

我有两个问题。首先,我希望列标题居中,(见屏幕截图)

第二,每次我在表格底部添加行来用“是”或“否”描述模型(年份和国家固定效应)时,乳胶都会显示错误。

查看我的代码、输出和所需的表格样式

代码:

  \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}

输出:

在此处输入图片描述

所需标题:

在此处输入图片描述

期望的底线:

在此处输入图片描述

答案1

像这样?

在此处输入图片描述

  • 您的表格主体内容与所需的列标题不接近:您显示了七个列标题,主体有十列...
  • 转录表体使表格变得更窄,因此可以采用纵向格式

编辑:
MWE,改善了表格行与行之间的距离:

\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}

笔记
如果表格不够长,即无法放在一页上,您可以考虑用 替换longtblrtalltblr然后将其插入table浮动中:

\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}

相关内容