首页 > 解决方案 > Latex 中的大表在输出为 PDF 时被截断?

问题描述

我没有使用太多 Latex 语法,所以我不太确定我需要在这里进行哪些风格化更改。

我有一大块这样的乳胶:

\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{center}
\begin{longtable}{|l|l|l|} \centering

\begin{tabular}{@{\extracolsep{5pt}}lcccccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
 & \multicolumn{8}{c}{\textit{Dependent variable:}} \\
\cline{2-9}
\\[-1.8ex] & \multicolumn{2}{c}{Female} & \multicolumn{4}{c}{NonWhite} & \multicolumn{2}{c}{Black.or.African.American} \\
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8)\\
\hline \\[-1.8ex]
 factor(ELECTORAL\_TERM)2018 & 0.104$^{***}$ & 0.104$^{***}$ & $-$0.104$^{***}$ & $-$0.104$^{***}$ & $-$0.103$^{***}$ & $-$0.103$^{***}$ & $-$0.047$^{***}$ & $-$0.047$^{***}$ \\
  & (0.010) & (0.010) & (0.009) & (0.009) & (0.009) & (0.009) & (0.006) & (0.006) \\
  & & & & & & & & \\
 factor(ELECTORAL\_TERM)2019 & 0.129$^{***}$ & 0.128$^{***}$ & 0.088$^{***}$ & 0.088$^{***}$ & 0.092$^{***}$ & 0.092$^{***}$ & 0.063$^{***}$ & 0.063$^{***}$ \\
  & (0.011) & (0.011) & (0.009) & (0.010) & (0.009) & (0.009) & (0.007) & (0.007) \\
  & & & & & & & & \\
 WOMENS\_RIGHTS\_PROTEST & $-$0.016 & $-$0.025 &  &  &  &  &  &  \\
  & (0.018) & (0.019) &  &  &  &  &  &  \\
  & & & & & & & & \\
 WOMENS\_RIGHTS\_COUNTERPROTEST &  & 0.052 &  &  &  &  &  &  \\
  &  & (0.043) &  &  &  &  &  &  \\
  & & & & & & & & \\
 RACIAL\_PROTEST &  &  & 0.032$^{***}$ & 0.032$^{***}$ &  &  & 0.020$^{***}$ & 0.021$^{***}$ \\
  &  &  & (0.010) & (0.011) &  &  & (0.007) & (0.008) \\
  & & & & & & & & \\
 RACIAL\_COUNTERPROTEST &  &  &  & 0.001 &  &  &  & $-$0.007 \\
  &  &  &  & (0.039) &  &  &  & (0.028) \\
  & & & & & & & & \\
 OTHER\_IDENTITY\_PROTEST &  &  &  &  & 0.057 & 0.068 &  &  \\
  &  &  &  &  & (0.077) & (0.078) &  &  \\
  & & & & & & & & \\
 OTHER\_IDENTITY\_COUNTERPROTEST &  &  &  &  &  & $-$0.116 &  &  \\
  &  &  &  &  &  & (0.156) &  &  \\
  & & & & & & & & \\
 Republican.Party & 0.061$^{***}$ & 0.061$^{***}$ & 0.068$^{***}$ & 0.068$^{***}$ & 0.068$^{***}$ & 0.068$^{***}$ & 0.027$^{***}$ & 0.027$^{***}$ \\
  & (0.014) & (0.014) & (0.012) & (0.012) & (0.012) & (0.012) & (0.009) & (0.009) \\
  & & & & & & & & \\
 Democratic.Party & 0.386$^{***}$ & 0.386$^{***}$ & 0.162$^{***}$ & 0.162$^{***}$ & 0.162$^{***}$ & 0.162$^{***}$ & 0.083$^{***}$ & 0.083$^{***}$ \\
  & (0.016) & (0.016) & (0.014) & (0.014) & (0.014) & (0.014) & (0.010) & (0.010) \\
  & & & & & & & & \\
 CIT\_EST\_White & $-$0.002 & $-$0.002 & 0.001 & 0.001 & 0.001 & 0.001 & 0.0002 & 0.0002 \\
  & (0.002) & (0.002) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) \\
  & & & & & & & & \\
 CIT\_EST\_African\_American & 0.007$^{**}$ & 0.007$^{**}$ & 0.001 & 0.001 & 0.001 & 0.001 & 0.0005 & 0.0005 \\
  & (0.004) & (0.004) & (0.003) & (0.003) & (0.003) & (0.003) & (0.002) & (0.002) \\
  & & & & & & & & \\
 CIT\_EST\_NonWhite & 0.014 & 0.014 & $-$0.004 & $-$0.004 & $-$0.004 & $-$0.004 & $-$0.002 & $-$0.002 \\
  & (0.011) & (0.011) & (0.009) & (0.009) & (0.009) & (0.009) & (0.007) & (0.007) \\
  & & & & & & & & \\
 CVAP\_EST\_White & 0.007 & 0.007 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.001 & $-$0.001 \\
  & (0.004) & (0.004) & (0.004) & (0.004) & (0.004) & (0.004) & (0.003) & (0.003) \\
  & & & & & & & & \\
 CVAP\_EST\_African\_American & $-$0.007 & $-$0.007 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.001 & $-$0.001 \\
  & (0.006) & (0.006) & (0.005) & (0.005) & (0.005) & (0.005) & (0.004) & (0.004) \\
  & & & & & & & & \\
 CVAP\_EST\_NonWhite & $-$0.020 & $-$0.020 & 0.006 & 0.006 & 0.006 & 0.006 & 0.002 & 0.002 \\
  & (0.016) & (0.016) & (0.014) & (0.014) & (0.014) & (0.014) & (0.010) & (0.010) \\
  & & & & & & & & \\
 Constant & $-$23.099 & $-$23.099 & 5.245 & 5.245 & 5.244 & 5.241 & 1.899 & 1.898 \\
  & (14.561) & (14.561) & (12.598) & (12.599) & (12.608) & (12.609) & (8.972) & (8.972) \\
  & & & & & & & & \\
\hline \\[-1.8ex]
Observations & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 \\
R$^{2}$ & 0.778 & 0.778 & 0.660 & 0.660 & 0.659 & 0.659 & 0.664 & 0.664 \\
Adjusted R$^{2}$ & 0.654 & 0.654 & 0.468 & 0.468 & 0.468 & 0.468 & 0.476 & 0.476 \\
Residual Std. Error & 0.403 (df = 6145) & 0.403 (df = 6144) & 0.348 (df = 6145) & 0.348 (df = 6144) & 0.349 (df = 6145) & 0.349 (df = 6144) & 0.248 (df = 6145) & 0.248 (df = 6144) \\
F Statistic & 6.250$^{***}$ (df = 3448; 6145) & 6.249$^{***}$ (df = 3449; 6144) & 3.452$^{***}$ (df = 3448; 6145) & 3.450$^{***}$ (df = 3449; 6144) & 3.443$^{***}$ (df = 3448; 6145) & 3.442$^{***}$ (df = 3449; 6144) & 3.524$^{***}$ (df = 3448; 6145) & 3.523$^{***}$ (df = 3449; 6144) \\
\hline
\hline \\[-1.8ex]
\textit{Note:}  & \multicolumn{8}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{longtable} 
\end{center}
\end{document}

但是,输出的 PDF 如下所示:

在此处输入图像描述

桌子的底部和右侧都被切断了。如您所见,我尝试使用 longtable ,但这似乎没有多大作用。我不确定我是否需要旋转表格,或者向右移动表格,或者允许额外的页面,或者什么。

标签: pdflatexpdflatexxelatexlongtable

解决方案


几个想法:

  • 不要tabularlongtable. Longtable 旨在代替使用,而不是围绕tabular

  • 如果您的表格已经太大而无法容纳页面,请不要通过手动添加使其更大extracolsep

  • 在横向使用纸张以获得更多空间

  • 减少边距

  • 使用固定宽度的列强制换行以使列更小

  • 第一列中的变量名称很长,latex 无法自动将它们连字符。定义可能的断点

  • df值放在新行中以使列更小

  • 如果这一切都没有帮助,请使用更大的纸张或将表格拆分为具有较少列的多个表格


\documentclass{article}
\usepackage{longtable}

\usepackage[landscape,hmargin=0.5cm]{geometry}
\begin{document}
\begin{longtable}{p{4.6cm}*{8}{p{1.7cm}}}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
 & \multicolumn{8}{c}{\textit{Dependent variable:}} \\
\cline{2-9}
\\[-1.8ex] & \multicolumn{2}{c}{Female} & \multicolumn{4}{c}{NonWhite} & \multicolumn{2}{c}{Black.or.Afr.Am.} \\
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8)\\
\hline \\[-1.8ex]
 factor(\-ELECTORAL\-\_TERM)2018 & 0.104$^{***}$ & 0.104$^{***}$ & $-$0.104$^{***}$ & $-$0.104$^{***}$ & $-$0.103$^{***}$ & $-$0.103$^{***}$ & $-$0.047$^{***}$ & $-$0.047$^{***}$ \\
  & (0.010) & (0.010) & (0.009) & (0.009) & (0.009) & (0.009) & (0.006) & (0.006) \\
  & & & & & & & & \\
 factor(\-ELECTORAL\-\_TERM)2019 & 0.129$^{***}$ & 0.128$^{***}$ & 0.088$^{***}$ & 0.088$^{***}$ & 0.092$^{***}$ & 0.092$^{***}$ & 0.063$^{***}$ & 0.063$^{***}$ \\
  & (0.011) & (0.011) & (0.009) & (0.010) & (0.009) & (0.009) & (0.007) & (0.007) \\
  & & & & & & & & \\
 WOMENS\-\_RIGHTS\-\_PROTEST & $-$0.016 & $-$0.025 &  &  &  &  &  &  \\
  & (0.018) & (0.019) &  &  &  &  &  &  \\
  & & & & & & & & \\
 WOMENS\-\_RIGHTS\-\_COUNTERPROTEST &  & 0.052 &  &  &  &  &  &  \\
  &  & (0.043) &  &  &  &  &  &  \\
  & & & & & & & & \\
 RACIAL\-\_PROTEST &  &  & 0.032$^{***}$ & 0.032$^{***}$ &  &  & 0.020$^{***}$ & 0.021$^{***}$ \\
  &  &  & (0.010) & (0.011) &  &  & (0.007) & (0.008) \\
  & & & & & & & & \\
 RACIAL\-\_COUNTERPROTEST &  &  &  & 0.001 &  &  &  & $-$0.007 \\
  &  &  &  & (0.039) &  &  &  & (0.028) \\
  & & & & & & & & \\
 OTHER\-\_IDENTITY\-\_PROTEST &  &  &  &  & 0.057 & 0.068 &  &  \\
  &  &  &  &  & (0.077) & (0.078) &  &  \\
  & & & & & & & & \\
 OTHER\-\_IDENTITY\-\_COUNTERPROTEST &  &  &  &  &  & $-$0.116 &  &  \\
  &  &  &  &  &  & (0.156) &  &  \\
  & & & & & & & & \\
 Republican.Party & 0.061$^{***}$ & 0.061$^{***}$ & 0.068$^{***}$ & 0.068$^{***}$ & 0.068$^{***}$ & 0.068$^{***}$ & 0.027$^{***}$ & 0.027$^{***}$ \\
  & (0.014) & (0.014) & (0.012) & (0.012) & (0.012) & (0.012) & (0.009) & (0.009) \\
  & & & & & & & & \\
 Democratic.Party & 0.386$^{***}$ & 0.386$^{***}$ & 0.162$^{***}$ & 0.162$^{***}$ & 0.162$^{***}$ & 0.162$^{***}$ & 0.083$^{***}$ & 0.083$^{***}$ \\
  & (0.016) & (0.016) & (0.014) & (0.014) & (0.014) & (0.014) & (0.010) & (0.010) \\
  & & & & & & & & \\
 CIT\-\_EST\-\_White & $-$0.002 & $-$0.002 & 0.001 & 0.001 & 0.001 & 0.001 & 0.0002 & 0.0002 \\
  & (0.002) & (0.002) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) & (0.001) \\
  & & & & & & & & \\
 CIT\-\_EST\-\_African\-\_American & 0.007$^{**}$ & 0.007$^{**}$ & 0.001 & 0.001 & 0.001 & 0.001 & 0.0005 & 0.0005 \\
  & (0.004) & (0.004) & (0.003) & (0.003) & (0.003) & (0.003) & (0.002) & (0.002) \\
  & & & & & & & & \\
 CIT\-\_EST\-\_NonWhite & 0.014 & 0.014 & $-$0.004 & $-$0.004 & $-$0.004 & $-$0.004 & $-$0.002 & $-$0.002 \\
  & (0.011) & (0.011) & (0.009) & (0.009) & (0.009) & (0.009) & (0.007) & (0.007) \\
  & & & & & & & & \\
 CVAP\-\_EST\-\_White & 0.007 & 0.007 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.001 & $-$0.001 \\
  & (0.004) & (0.004) & (0.004) & (0.004) & (0.004) & (0.004) & (0.003) & (0.003) \\
  & & & & & & & & \\
 CVAP\-\_EST\-\_African\-\_American & $-$0.007 & $-$0.007 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.002 & $-$0.001 & $-$0.001 \\
  & (0.006) & (0.006) & (0.005) & (0.005) & (0.005) & (0.005) & (0.004) & (0.004) \\
  & & & & & & & & \\
 CVAP\-\_EST\-\_NonWhite & $-$0.020 & $-$0.020 & 0.006 & 0.006 & 0.006 & 0.006 & 0.002 & 0.002 \\
  & (0.016) & (0.016) & (0.014) & (0.014) & (0.014) & (0.014) & (0.010) & (0.010) \\
  & & & & & & & & \\
 Constant & $-$23.099 & $-$23.099 & 5.245 & 5.245 & 5.244 & 5.241 & 1.899 & 1.898 \\
  & (14.561) & (14.561) & (12.598) & (12.599) & (12.608) & (12.609) & (8.972) & (8.972) \\
  & & & & & & & & \\
\hline \\[-1.8ex]
Observations & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 & 9,594 \\
R$^{2}$ & 0.778 & 0.778 & 0.660 & 0.660 & 0.659 & 0.659 & 0.664 & 0.664 \\
Adjusted R$^{2}$ & 0.654 & 0.654 & 0.468 & 0.468 & 0.468 & 0.468 & 0.476 & 0.476 \\
Residual Std. Error & 0.403  & 0.403  & 0.348  & 0.348  & 0.349  & 0.349  & 0.248  & 0.248  \\
df & xxx & xxx & xxx & xxx & xxx & xxx & xxx & xxx \\
F Statistic & 6.250$^{***}$  & 6.249$^{***}$  & 3.452$^{***}$ & 3.450$^{***}$  & 3.443$^{***}$  & 3.442$^{***}$  & 3.524$^{***}$ & 3.523$^{***}$  \\
df & xxx & xxx & xxx & xxx & xxx & xxx & xxx & xxx \\
\hline
\hline \\[-1.8ex]
\textit{Note:}  & \multicolumn{8}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{longtable} 
\end{document}

推荐阅读