我的标题由两个单词组成,因此表格太宽了。我尝试在 Word 中使用相同的表格。如果标题可以分成两行,每个单词占一行,那么表格就可以完美固定。但是,我查看了大多数相关答案,无法在 texstudio 中解决。如果您能帮忙,我将不胜感激!
\documentclass[a4paper, 12pt]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{multirow}
\usepackage{mathtools}
\usepackage{commath}
\usepackage{amsmath,amssymb}
\DeclareMathOperator{\E}{\mathbb{E}}
\numberwithin{equation}{section}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{filecontents}
\usepackage[round]{natbib}
\usepackage{pdflscape}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage[short]{optidef}
\usepackage[justification=centering]{caption}
\begin{document}
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Demographic Factors for Risky Assets (Pooled Sample) \label{pooledrisky}}
\begin{tabular*}{1\hsize}{@{\hskip\tabcolsep\extracolsep\fill}l*{6}{D{.}{.}{-1}}}
\toprule
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}&\multicolumn{1}{c}{(6)}\\
&\multicolumn{1}{c}{probit}&\multicolumn{1}{c}{Tobit}&\multicolumn{1}{c}{Tobit\text{ }Censored}&\multicolumn{1}{c}{Tobit \text{ }Truncated}&\multicolumn{1}{c}{Truncated\text{ }Regression}&\multicolumn{1}{c}{Heckman}\\
\midrule
LnInc & 0.0429\sym{***}& 17.28\sym{***}& 1.208 & 2.618 & -1.346 & 0.468 \\
& (0.00425) & (1.863) & (4.635) & (2.932) & (1.132) & (2.500) \\
\addlinespace
Age & -0.000561 & 0.0991 & 0.00693 & 0.0150 & 1.014 & 0.590 \\
& (0.00293) & (1.251) & (0.0914) & (0.190) & (0.796) & (0.672) \\
\addlinespace
Kid & -0.00309 & -2.332 & -0.163 & -0.353 & -2.843 & -1.789 \\
& (0.00926) & (3.992) & (0.685) & (0.722) & (2.907) & (2.040) \\
\addlinespace
Old & 0.0321\sym{***}& 13.36\sym{***}& 0.934 & 2.025 & -0.527 & 0.594 \\
& (0.00992) & (4.260) & (3.597) & (2.348) & (2.861) & (2.352) \\
\addlinespace
HHsize & -0.0210\sym{***}& -8.944\sym{***}& -0.625 & -1.355 & 1.349 & 0.143 \\
& (0.00552) & (2.398) & (2.405) & (1.554) & (1.816) & (1.820) \\
\addlinespace
Male & -0.0103 & -4.335 & -0.303 & -0.657 & 1.060 & 0.257 \\
& (0.00945) & (4.043) & (1.197) & (0.955) & (2.554) & (1.807) \\
\addlinespace
Married & 0.0291\sym{*} & 10.48 & 0.733 & 1.588 & -4.646 & -1.836 \\
& (0.0169) & (7.189) & (2.855) & (2.078) & (4.680) & (4.384) \\
\addlinespace
Party & 0.00880 & 4.225 & 0.295 & 0.640 & 0.101 & 0.269 \\
& (0.0112) & (4.738) & (1.181) & (1.012) & (2.755) & (1.680) \\
\addlinespace
Job & -0.0341\sym{***}& -15.56\sym{***}& -1.088 & -2.358 & -2.167 & -2.262 \\
& (0.0118) & (5.080) & (4.189) & (2.739) & (3.370) & (2.078) \\
\addlinespace
House & 0.0508\sym{***}& 20.74\sym{***}& 1.450 & 3.143 & -1.161 & 0.920 \\
& (0.0158) & (6.798) & (5.584) & (3.652) & (4.567) & (3.741) \\
\addlinespace
Age 25-30 & -0.0393 & -10.86 & -0.759 & -1.645 & 9.263 & 5.502 \\
& (0.0882) & (37.69) & (3.927) & (5.998) & (23.97) & (15.73) \\
\addlinespace
Age 30-35 & 0.0157 & 13.30 & 0.930 & 2.016 & 18.88 & 11.86 \\
& (0.0746) & (31.87) & (4.206) & (5.326) & (20.26) & (14.39) \\
\addlinespace
Age 35-40 & 0.0243 & 16.91 & 1.182 & 2.562 & 17.29 & 11.11 \\
& (0.0598) & (25.56) & (4.875) & (4.812) & (16.27) & (11.79) \\
\addlinespace
Age 40-45 & 0.0442 & 24.83 & 1.736 & 3.763 & 15.12 & 10.42 \\
& (0.0464) & (19.86) & (6.803) & (5.162) & (12.84) & (9.123) \\
\addlinespace
Age 45-50 & 0.0316 & 16.68 & 1.166 & 2.527 & 7.181 & 5.297 \\
& (0.0327) & (14.02) & (4.580) & (3.529) & (9.280) & (5.807) \\
\midrule
Observations & 5174 & 5270 & 5270 & 5270 & 678 & 5270 \\
Log lik. & -1521.7 & -4817.8 & -4817.8 & -4817.8 & -3184.3 & \\
Chi-squared & 975.4 & 981.8 & 981.8 & 981.8 & 54.60 & 59.78 \\
\bottomrule
\multicolumn{7}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{7}{l}{\footnotesize \sym{*} \(p<0.1\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\
\end{tabular*}
\end{table}
\end{document}
答案1
像这样?
你遇到的问题不仅仅是将单元格内容拆分成更多行。为了解决这些问题,我采取了以下措施:
- 用于多行标题,
\makecell{...}
来自makcell
包 - 更正了列之间的间距
- 而不是
D
使用S
来自siunitx
包的列(列之间的间距较小) - 使用small
字体大小,否则你的表格太高 - 将大小
\addlinspace
从默认值减少到2pt
\documentclass[a4paper, 12pt]{article}
\usepackage[showframe]{geometry}
\usepackage{booktabs, makecell, multirow, tabularx}
%\usepackage{booktabs} % loading ones is sufficient ... :)
\usepackage{mathtools}
\usepackage{commath}
\usepackage{amsmath,amsfonts,amssymb}
\DeclareMathOperator{\E}{\mathbb{E}}
\numberwithin{equation}{section}
%usepackage{graphicx}
%\usepackage{filecontents}
%\usepackage[round]{natbib}
%\usepackage{pdflscape}
%\usepackage{float}
%\usepackage{tikz}
%\usepackage{pgfplots}
%\usepackage{filecontents}
%\usepackage{pgfplots}
%\usepackage{pgfplotstable}
%\usepackage[short]{optidef}
\usepackage[justification=centering]{caption}
\usepackage{siunitx}
\begin{document}
\begin{table}[htbp]
\centering
\small
\sisetup{ input-symbols = {()},
table-space-text-post=*** ,% <-- for spacing ***
table-align-text-post=false}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\setlength\tabcolsep{0pt}
\caption{Demographic Factors for Risky Assets (Pooled Sample) \label{pooledrisky}}
\begin{tabular*}{1\linewidth}{@{\hspace{6pt}\extracolsep{\fill}}
l
S[table-format=-1.5]
*{5}{S[table-format=-2.3]
}
@{}}
\toprule
& {\makecell[t]{(1)\\ probit}}
& {\makecell[t]{(2)\\Tobit}}
& {\makecell[t]{(3)\\Tobit\\ Censored}}
& {\makecell[t]{(4)\\Tobit\\ Truncated}}
& {\makecell[t]{(5)\\Truncated\\ Regression}}
& {\makecell[t]{(6)\\Heckman}} \\
\midrule
LnInc & 0.0429\sym{***} & 17.28\sym{***} & 1.208 & 2.618 & -1.346 & 0.468 \\
& (0.00425) & (1.863) & (4.635) & (2.932) & (1.132) & (2.500) \\
\addlinespace[2pt]
Age & -0.000561 & 0.0991 & 0.00693 & 0.0150 & 1.014 & 0.590 \\
& (0.00293) & (1.251) & (0.0914) & (0.190) & (0.796) & (0.672) \\
\addlinespace[2pt]
Kid & -0.00309 & -2.332 & -0.163 & -0.353 & -2.843 & -1.789 \\
& (0.00926) & (3.992) & (0.685) & (0.722) & (2.907) & (2.040) \\
\addlinespace[2pt]
Old & 0.0321\sym{***}& 13.36\sym{***}& 0.934 & 2.025 & -0.527 & 0.594 \\
& (0.00992) & (4.260) & (3.597) & (2.348) & (2.861) & (2.352) \\
\addlinespace[2pt]
HHsize & -0.0210\sym{***}& -8.944\sym{***}& -0.625 & -1.355 & 1.349 & 0.143 \\
& (0.00552) & (2.398) & (2.405) & (1.554) & (1.816) & (1.820) \\
\addlinespace[2pt]
Male & -0.0103 & -4.335 & -0.303 & -0.657 & 1.060 & 0.257 \\
& (0.00945) & (4.043) & (1.197) & (0.955) & (2.554) & (1.807) \\
\addlinespace[2pt]
Married & 0.0291\sym{*} & 10.48 & 0.733 & 1.588 & -4.646 & -1.836 \\
& (0.0169) & (7.189) & (2.855) & (2.078) & (4.680) & (4.384) \\
\addlinespace[2pt]
Party & 0.00880 & 4.225 & 0.295 & 0.640 & 0.101 & 0.269 \\
& (0.0112) & (4.738) & (1.181) & (1.012) & (2.755) & (1.680) \\
\addlinespace[2pt]
Job & -0.0341\sym{***}& -15.56\sym{***}& -1.088 & -2.358 & -2.167 & -2.262 \\
& (0.0118) & (5.080) & (4.189) & (2.739) & (3.370) & (2.078) \\
\addlinespace[2pt]
House & 0.0508\sym{***}& 20.74\sym{***}& 1.450 & 3.143 & -1.161 & 0.920 \\
& (0.0158) & (6.798) & (5.584) & (3.652) & (4.567) & (3.741) \\
\addlinespace[2pt]
Age 25-30 & -0.0393 & -10.86 & -0.759 & -1.645 & 9.263 & 5.502 \\
& (0.0882) & (37.69) & (3.927) & (5.998) & (23.97) & (15.73) \\
\addlinespace[2pt]
Age 30-35 & 0.0157 & 13.30 & 0.930 & 2.016 & 18.88 & 11.86 \\
& (0.0746) & (31.87) & (4.206) & (5.326) & (20.26) & (14.39) \\
\addlinespace[2pt]
Age 35-40 & 0.0243 & 16.91 & 1.182 & 2.562 & 17.29 & 11.11 \\
& (0.0598) & (25.56) & (4.875) & (4.812) & (16.27) & (11.79) \\
\addlinespace[2pt]
Age 40-45 & 0.0442 & 24.83 & 1.736 & 3.763 & 15.12 & 10.42 \\
& (0.0464) & (19.86) & (6.803) & (5.162) & (12.84) & (9.123) \\
\addlinespace[2pt]
Age 45-50 & 0.0316 & 16.68 & 1.166 & 2.527 & 7.181 & 5.297 \\
& (0.0327) & (14.02) & (4.580) & (3.529) & (9.280) & (5.807) \\
\midrule
Observations & 5174 & 5270 & 5270 & 5270 & 678 & 5270 \\
Log lik. & -1521.7 & -4817.8 & -4817.8 & -4817.8 & -3184.3 & \\
Chi-squared & 975.4 & 981.8 & 981.8 & 981.8 & 54.60 & 59.78 \\
\bottomrule
\multicolumn{7}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{7}{l}{\footnotesize \sym{*} \(p<0.1\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\
\end{tabular*}
\end{table}