我正在使用 Rstudio 的一个软件包,它为我提供了 Latex 代码中的表格。不幸的是,我得到的表格太大了,超出了页面的边缘。我已经尝试过了,\small
但还不够。我读过\resizebox
或\adjustbox
,但它们似乎不起作用......(我确定我无法应用它们。这是我第一次使用 Latex)
这是我的代码
\usepackage[landscape]{geometry}
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{@{\extracolsep{5pt}}lcccccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multicolumn{8}{c}{\textit{Dependent variable:}} \\
\cline{2-9}
\\[-1.8ex] & \multicolumn{8}{c}{log(tpens)} \\
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8)\\
\hline \\[-1.8ex]
sex & 0.226$^{***}$ & 0.219$^{***}$ & 0.239$^{***}$ & 0.244$^{***}$ & 0.131$^{***}$ & 0.132$^{***}$ & 0.132$^{***}$ & 0.142$^{***}$ \\
& (0.020) & (0.019) & (0.017) & (0.017) & (0.016) & (0.016) & (0.016) & (0.016) \\
& & & & & & & & \\
eta & & $-$0.009$^{***}$ & $-$0.005$^{***}$ & $-$0.004$^{***}$ & $-$0.002$^{**}$ & $-$0.002$^{**}$ & $-$0.002$^{**}$ & $-$0.002$^{*}$ \\
& & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) \\
& & & & & & & & \\
studio\_lev2 & & & 0.330$^{***}$ & 0.163$^{***}$ & 0.129$^{***}$ & 0.127$^{***}$ & 0.127$^{***}$ & 0.129$^{***}$ \\
& & & (0.021) & (0.023) & (0.022) & (0.022) & (0.022) & (0.022) \\
& & & & & & & & \\
studio\_lev3 & & & 0.717$^{***}$ & 0.459$^{***}$ & 0.420$^{***}$ & 0.417$^{***}$ & 0.417$^{***}$ & 0.431$^{***}$ \\
& & & (0.035) & (0.038) & (0.036) & (0.036) & (0.036) & (0.036) \\
& & & & & & & & \\
type\_job\_Middle-class\_worker & & & & 0.219$^{***}$ & 0.189$^{***}$ & 0.187$^{***}$ & 0.187$^{***}$ & 0.191$^{***}$ \\
& & & & (0.023) & (0.022) & (0.022) & (0.022) & (0.022) \\
& & & & & & & & \\
type\_job\_Manager & & & & 0.465$^{***}$ & 0.418$^{***}$ & 0.414$^{***}$ & 0.414$^{***}$ & 0.410$^{***}$ \\
& & & & (0.039) & (0.037) & (0.037) & (0.037) & (0.036) \\
& & & & & & & & \\
type\_job\_Self-Employed & & & & $-$0.142$^{***}$ & $-$0.189$^{***}$ & $-$0.190$^{***}$ & $-$0.189$^{***}$ & $-$0.173$^{***}$ \\
& & & & (0.022) & (0.020) & (0.020) & (0.020) & (0.020) \\
& & & & & & & & \\
acontrib & & & & & 0.020$^{***}$ & 0.020$^{***}$ & 0.020$^{***}$ & 0.019$^{***}$ \\
& & & & & (0.001) & (0.001) & (0.001) & (0.001) \\
& & & & & & & & \\
dislav & & & & & & $-$0.085$^{***}$ & $-$0.085$^{***}$ & $-$0.050$^{*}$ \\
& & & & & & (0.027) & (0.027) & (0.027) \\
& & & & & & & & \\
occnow & & & & & & & 0.029 & 0.075 \\
& & & & & & & (0.072) & (0.073) \\
& & & & & & & & \\
ireg2 & & & & & & & & 0.147$^{*}$ \\
& & & & & & & & (0.080) \\
& & & & & & & & \\
ireg3 & & & & & & & & $-$0.005 \\
& & & & & & & & (0.032) \\
& & & & & & & & \\
ireg4 & & & & & & & & $-$0.054 \\
& & & & & & & & (0.039) \\
& & & & & & & & \\
ireg5 & & & & & & & & $-$0.012 \\
& & & & & & & & (0.034) \\
& & & & & & & & \\
ireg6 & & & & & & & & 0.067 \\
& & & & & & & & (0.050) \\
& & & & & & & & \\
ireg7 & & & & & & & & $-$0.080$^{*}$ \\
& & & & & & & & (0.043) \\
& & & & & & & & \\
ireg8 & & & & & & & & 0.076$^{**}$ \\
& & & & & & & & (0.036) \\
& & & & & & & & \\
ireg9 & & & & & & & & $-$0.018 \\
& & & & & & & & (0.033) \\
& & & & & & & & \\
ireg10 & & & & & & & & $-$0.071 \\
& & & & & & & & (0.045) \\
& & & & & & & & \\
ireg11 & & & & & & & & 0.050 \\
& & & & & & & & (0.041) \\
& & & & & & & & \\
ireg12 & & & & & & & & 0.012 \\
& & & & & & & & (0.038) \\
& & & & & & & & \\
ireg13 & & & & & & & & $-$0.099$^{*}$ \\
& & & & & & & & (0.060) \\
& & & & & & & & \\
ireg14 & & & & & & & & $-$0.217$^{***}$ \\
& & & & & & & & (0.056) \\
& & & & & & & & \\
ireg15 & & & & & & & & $-$0.091$^{**}$ \\
& & & & & & & & (0.039) \\
& & & & & & & & \\
ireg16 & & & & & & & & $-$0.120$^{***}$ \\
& & & & & & & & (0.040) \\
& & & & & & & & \\
ireg17 & & & & & & & & $-$0.176$^{***}$ \\
& & & & & & & & (0.054) \\
& & & & & & & & \\
ireg18 & & & & & & & & $-$0.019 \\
& & & & & & & & (0.046) \\
& & & & & & & & \\
ireg19 & & & & & & & & $-$0.126$^{***}$ \\
& & & & & & & & (0.044) \\
& & & & & & & & \\
ireg20 & & & & & & & & $-$0.021 \\
& & & & & & & & (0.039) \\
& & & & & & & & \\
Constant & 6.860$^{***}$ & 7.530$^{***}$ & 7.133$^{***}$ & 7.034$^{***}$ & 6.273$^{***}$ & 6.324$^{***}$ & 6.266$^{***}$ & 6.171$^{***}$ \\
& (0.015) & (0.089) & (0.082) & (0.078) & (0.082) & (0.083) & (0.166) & (0.170) \\
& & & & & & & & \\
\hline \\[-1.8ex]
Observations & 2,229 & 2,229 & 2,229 & 2,226 & 2,173 & 2,173 & 2,173 & 2,173 \\
R$^{2}$ & 0.056 & 0.081 & 0.270 & 0.358 & 0.455 & 0.457 & 0.457 & 0.476 \\
Adjusted R$^{2}$ & 0.056 & 0.080 & 0.269 & 0.356 & 0.453 & 0.455 & 0.455 & 0.469 \\
Residual Std. Error & 0.406 (df = 2227) & 0.400 (df = 2226) & 0.357 (df = 2224) & 0.335 (df = 2218) & 0.309 (df = 2164) & 0.309 (df = 2163) & 0.309 (df = 2162) & 0.305 (df = 2143) \\
F Statistic & 133.081$^{***}$ (df = 1; 2227) & 97.706$^{***}$ (df = 2; 2226) & 206.134$^{***}$ (df = 4; 2224) & 176.461$^{***}$ (df = 7; 2218) & 225.471$^{***}$ (df = 8; 2164) & 202.428$^{***}$ (df = 9; 2163) & 182.131$^{***}$ (df = 10; 2162) & 67.151$^{***}$ (df = 29; 2143) \\
\hline
\hline \\[-1.8ex]
\textit{Note:} & \multicolumn{8}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{table}
我该如何解决?我需要一些东西来减少列和行之间的所有空白,以便将表格放入页面中
答案1
如果将自由度 (df) 信息放在单独的行上,则无需将表格转换为横向格式。由于表格的行数超出一页的容量,我建议您使用长桌环境而不是table
/tabular
组合。
\documentclass{article} % or some other suitable document class
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry} % set page parameters appropriately
\usepackage{longtable}
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{dcolumn} % align numbers in columns on decimal markers
\newcolumntype{d}[1]{D..{#1}}
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begingroup % localize scope of next four instructions
\small % 10% linear reduction in font size
\setlength\tabcolsep{0pt} % let LaTeX figure out inter-column space
\setlength\LTleft{0pt} % see p. 7 of package's user guide
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}} l *{7}{d{2.5}} d{2.6} @{}}
%% headers and footers
\caption{X} \label{tab:x} \\
\toprule
& \multicolumn{8}{c}{\textit{Dependent variable:}} \\
& \multicolumn{8}{c}{$\log(\mathrm{tpens})$} \\
\cmidrule{2-9}
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)}
& \mc{(5)} & \mc{(6)} & \mc{(7)} & \mc{(8)}\\
\midrule
\endfirsthead
\multicolumn{9}{@{}l}{Table \thetable, continued}\\
\addlinespace
\toprule
& \multicolumn{8}{c}{\textit{Dependent variable:}} \\
& \multicolumn{8}{c}{$\log(\mathrm{tpens})$} \\
\cmidrule{2-9}
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)}
& \mc{(5)} & \mc{(6)} & \mc{(7)} & \mc{(8)}\\
\midrule
\endhead
\midrule
\multicolumn{9}{r@{}}{\footnotesize (continued on next page)}\\
\endfoot
% empty final footer
\endlastfoot
%% body of table
sex & 0.226^{***} & 0.219^{***} & 0.239^{***} & 0.244^{***} & 0.131^{***} & 0.132^{***} & 0.132^{***} & 0.142^{***} \\
& (0.020) & (0.019) & (0.017) & (0.017) & (0.016) & (0.016) & (0.016) & (0.016) \\
\addlinespace
eta & & -0.009^{***} & -0.005^{***} & -0.004^{***} & -0.002^{**} & -0.002^{**} & -0.002^{**} & -0.002^{*} \\
& & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) \\
\addlinespace
studio\_lev2 & & & 0.330^{***} & 0.163^{***} & 0.129^{***} & 0.127^{***} & 0.127^{***} & 0.129^{***} \\
& & & (0.021) & (0.023) & (0.022) & (0.022) & (0.022) & (0.022) \\
\addlinespace
studio\_lev3 & & & 0.717^{***} & 0.459^{***} & 0.420^{***} & 0.417^{***} & 0.417^{***} & 0.431^{***} \\
& & & (0.035) & (0.038) & (0.036) & (0.036) & (0.036) & (0.036) \\
\addlinespace
type\_job\_Middle-class\_worker & & & & 0.219^{***} & 0.189^{***} & 0.187^{***} & 0.187^{***} & 0.191^{***} \\
& & & & (0.023) & (0.022) & (0.022) & (0.022) & (0.022) \\
\addlinespace
type\_job\_Manager & & & & 0.465^{***} & 0.418^{***} & 0.414^{***} & 0.414^{***} & 0.410^{***} \\
& & & & (0.039) & (0.037) & (0.037) & (0.037) & (0.036) \\
\addlinespace
type\_job\_Self-Employed & & & & -0.142^{***} & -0.189^{***} & -0.190^{***} & -0.189^{***} & -0.173^{***} \\
& & & & (0.022) & (0.020) & (0.020) & (0.020) & (0.020) \\
\addlinespace
acontrib & & & & & 0.020^{***} & 0.020^{***} & 0.020^{***} & 0.019^{***} \\
& & & & & (0.001) & (0.001) & (0.001) & (0.001) \\
\addlinespace
dislav & & & & & & -0.085^{***} & -0.085^{***} & -0.050^{*} \\
& & & & & & (0.027) & (0.027) & (0.027) \\
\addlinespace
occnow & & & & & & & 0.029 & 0.075 \\
& & & & & & & (0.072) & (0.073) \\
\addlinespace
ireg2 & & & & & & & & 0.147^{*} \\
& & & & & & & & (0.080) \\
\addlinespace
ireg3 & & & & & & & & -0.005 \\
& & & & & & & & (0.032) \\
\addlinespace
ireg4 & & & & & & & & -0.054 \\
& & & & & & & & (0.039) \\
\addlinespace
ireg5 & & & & & & & & -0.012 \\
& & & & & & & & (0.034) \\
\addlinespace
ireg6 & & & & & & & & 0.067 \\
& & & & & & & & (0.050) \\
\addlinespace
ireg7 & & & & & & & & -0.080^{*} \\
& & & & & & & & (0.043) \\
\addlinespace
ireg8 & & & & & & & & 0.076^{**} \\
& & & & & & & & (0.036) \\
\addlinespace
ireg9 & & & & & & & & -0.018 \\
& & & & & & & & (0.033) \\
\addlinespace
ireg10 & & & & & & & & -0.071 \\
& & & & & & & & (0.045) \\
\addlinespace
ireg11 & & & & & & & & 0.050 \\
& & & & & & & & (0.041) \\
\addlinespace
ireg12 & & & & & & & & 0.012 \\
& & & & & & & & (0.038) \\
\addlinespace
ireg13 & & & & & & & & -0.099^{*} \\
& & & & & & & & (0.060) \\
\addlinespace
ireg14 & & & & & & & & -0.217^{***} \\
& & & & & & & & (0.056) \\
\addlinespace
ireg15 & & & & & & & & -0.091^{**} \\
& & & & & & & & (0.039) \\
\addlinespace
ireg16 & & & & & & & & -0.120^{***} \\
& & & & & & & & (0.040) \\
\addlinespace
ireg17 & & & & & & & & -0.176^{***} \\
& & & & & & & & (0.054) \\
\addlinespace
ireg18 & & & & & & & & -0.019 \\
& & & & & & & & (0.046) \\
\addlinespace
ireg19 & & & & & & & & -0.126^{***} \\
& & & & & & & & (0.044) \\
\addlinespace
ireg20 & & & & & & & & -0.021 \\
& & & & & & & & (0.039) \\
\addlinespace
Constant & 6.860^{***} & 7.530^{***} & 7.133^{***} & 7.034^{***} & 6.273^{***} & 6.324^{***} & 6.266^{***} & 6.171^{***} \\
& (0.015) & (0.089) & (0.082) & (0.078) & (0.082) & (0.083) & (0.166) & (0.170) \\
\midrule
Observations & \mc{2{,}229} & \mc{2{,}229} & \mc{2{,}229} & \mc{2{,}226} & \mc{2{,}173} & \mc{2{,}173} & \mc{2{,}173} & \mc{2{,}173} \\
$R^{2}$ & 0.056 & 0.081 & 0.270 & 0.358 & 0.455 & 0.457 & 0.457 & 0.476 \\
Adjusted $R^{2}$ & 0.056 & 0.080 & 0.269 & 0.356 & 0.453 & 0.455 & 0.455 & 0.469 \\
Resid.\ Std.\ Error & 0.406 & 0.400 & 0.357 & 0.335 & 0.309 & 0.309 & 0.309 & 0.305 \\
\qquad df & \mc{2227} & \mc{2226} & \mc{2224} & \mc{2218} & \mc{2164} & \mc{2163} & \mc{2162} & \mc{2143} \\
$F$-Statistic
& \mc{133.081} & \mc{97.706} & \mc{206.134} & \mc{176.461} & \mc{225.471 } & \mc{202.428} & \mc{182.131} & \mc{67.151} \\
\qquad df & \mc{1;2227} & \mc{2;2226} & \mc{4;2224} & \mc{7;2218} & \mc{8;2164} & \mc{9;2163} & \mc{10;2162} & \mc{29;2143} \\
\bottomrule
\addlinespace
\multicolumn{9}{@{}l}{\textit{Note}: $^{*}\ p<0.1$; $^{**}\ p<0.05$; $^{***}\ p<0.01$} \\
\end{longtable}
\endgroup
\end{document}