使用来自 talltblr 的 @zarko 的最新建议,现在我想要的表格有一个模型(每个标题一列)
做了一些修改,新表仍然超出了边距。以下是代码和输出
\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}
输出 :
现在使用对@zarko 原始命题的修改,我开始接近所需的表格;但 texniccenter 显示多次:缺失数字被视为零:
\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}
输出 :
答案1
- 假设您希望有三对“资本流动”列,即总共六列
- 列规范有误。应为:
colspec = {@{} Q[l,h, font=\scshape]
*{6}{X[c, m, si]} % observe 6
@{}},
- 每行必须插入所有 & 符号。禁止跳过其中某些符号
- 正确的 MWE 可以(应该)是:
\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}
附录:
- 我还是不确定你想要什么。
- 根据您的评论,我猜测您实际上喜欢有 1 + 3 列的表格,如下所示:
- MWE,其中
- 删除表体中的所有多列单元格,
- 修正后的
\subtitle
命令现在跨越四列, - 在表格前言中仅定义了四列,
X
列类型被替换Q
,因此表格更窄,- 改进单元格内容周围的垂直间距:
\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}