桌子分隔得太宽

桌子分隔得太宽

对于我的论文,我试图展示互相关分析的结果,但由于变量数量太多,表格结果无论我如何排列都会太宽。我想知道是否有办法将其分成两部分(可能是为了让它保持在同一页上)。

下面您可以找到我从 STATA 获得的代码。

    \documentclass[12pt]{article}

\usepackage{longtable}
\usepackage{threeparttable}

\begin{document}
    \begin{center}
    \begin{threeparttable}
    \begin{longtable}{l  c  c  c  c  c  c  c  c  c  c  c }
    \caption{Cross-correlation table\label{corrtable}}\\ 
     \hline\hline
    \endfirsthead
    \multicolumn{12}{l}{\emph{... table \thetable{} continued}}
     \\ \hline 
    \endhead
    \hline
    \multicolumn{12}{r}{\emph{Continued on next page...}}\\
    \endfoot
    \hline\hline
    \endlastfoot
    \multicolumn{1}{c}{Variables} & investments & Cross-border& Domestic & Early&GDP &Market Cap. & CPI & PRS &AS&IPO &Sales\\ \hline
    investments&1.000\\
    Cross-border &0.885&1.000\\
    Domestic &0.571&0.122&1.000\\
    Early &0.758&0.849&0.118&1.000\\
    GDP &0.168&0.073&0.230&0.072&1.000\\
    Market Cap. &0.012&-0.019&0.059&0.013&-0.182&1.000\\
    CPI &0.195&0.107&0.227&0.088&0.096&0.008&1.000\\
    PRS &0.133&0.099&0.110&0.102&0.088&-0.085&0.695&1.000\\
    AS&-0.201&-0.074&-0.298&-0.028&-0.172&-0.072&-0.522&-0.442&1.000\\
    IPO &0.077&-0.038&0.231&0.004&0.038&0.131&0.178&0.020&-0.011&1.000\\
    Sales &0.126&0.060&0.163&-0.001&0.139&-0.175&0.373&0.312&-0.379&0.026&1.000\\
    \end{longtable}

    \end{threeparttable}
    \end{center}



\end{document}

PS 我尝试使用()将其设置在一侧\landscape,但最后两列仍然不可见。

答案1

您不需要这样做longtable,因为十二行表格不应该跨页拆分。

我们可以通过避免重复标题并为标题添加数字(也为行设置)来节省空间。

这里有两个适合标准文本宽度的版本,一个是缩小的字体大小,另一个是旋转的字体大小。

\documentclass[12pt]{article}

\usepackage{longtable}
\usepackage{booktabs,siunitx,rotating}

\begin{document}

\begin{table}[htp]
\caption{Cross-correlation table\label{corrtable}}

\scriptsize
\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  r@{ }l
  *{11}{S[table-format=-1.3]}
  @{}
}
\toprule
\multicolumn{2}{@{}c}{Variables} &
  {(1)} & {(2)} & {(3)} & {(4)} & {(5)} &
  {(6)} & {(7)} & {(8)} & {(9)} & {(10)} & {(11)} \\
\midrule
(1)  & Investments&1.000\\
(2)  & Cross-border &0.885&1.000\\
(3)  & Domestic &0.571&0.122&1.000\\
(4)  & Early &0.758&0.849&0.118&1.000\\
(5)  & GDP &0.168&0.073&0.230&0.072&1.000\\
(6)  & Market Cap. &0.012&-0.019&0.059&0.013&-0.182&1.000\\
(7)  &  CPI &0.195&0.107&0.227&0.088&0.096&0.008&1.000\\
(8)  & PRS &0.133&0.099&0.110&0.102&0.088&-0.085&0.695&1.000\\
(9)  & AS&-0.201&-0.074&-0.298&-0.028&-0.172&-0.072&-0.522&-0.442&1.000\\
(10) & IPO &0.077&-0.038&0.231&0.004&0.038&0.131&0.178&0.020&-0.011&1.000\\
(11) & Sales &0.126&0.060&0.163&-0.001&0.139&-0.175&0.373&0.312&-0.379&0.026&1.000\\
\bottomrule
\end{tabular*}

\end{table}

\begin{sidewaystable}
\caption{Cross-correlation table\label{corrtable-sideways}}

\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  r@{ }l
  *{11}{S[table-format=-1.3]}
  @{}
}
\toprule
\multicolumn{2}{@{}c}{Variables} &
  {(1)} & {(2)} & {(3)} & {(4)} & {(5)} &
  {(6)} & {(7)} & {(8)} & {(9)} & {(10)} & {(11)} \\
\midrule
(1)  & Investments&1.000\\
(2)  & Cross-border &0.885&1.000\\
(3)  & Domestic &0.571&0.122&1.000\\
(4)  & Early &0.758&0.849&0.118&1.000\\
(5)  & GDP &0.168&0.073&0.230&0.072&1.000\\
(6)  & Market Cap. &0.012&-0.019&0.059&0.013&-0.182&1.000\\
(7)  &  CPI &0.195&0.107&0.227&0.088&0.096&0.008&1.000\\
(8)  & PRS &0.133&0.099&0.110&0.102&0.088&-0.085&0.695&1.000\\
(9)  & AS&-0.201&-0.074&-0.298&-0.028&-0.172&-0.072&-0.522&-0.442&1.000\\
(10) & IPO &0.077&-0.038&0.231&0.004&0.038&0.131&0.178&0.020&-0.011&1.000\\
(11) & Sales &0.126&0.060&0.163&-0.001&0.139&-0.175&0.373&0.312&-0.379&0.026&1.000\\
\bottomrule
\end{tabular*}

\end{sidewaystable}

\end{document}

在此处输入图片描述

答案2

如果可以的话,它可以适应文本高度(横向模式)

  • 加载geometry以获得更可观的利润,
  • 调整字体大小和列间距,
  • 用于makecell有多行列标题。

这里是经过各种改进的代码:使用siunitx数字的格式和对齐方式,使用 booktabs 中的规则以获得更专业的外观(特别是,它们添加了一些垂直填充。O 重新组织了代码,以便将列标题放入各个\endhead/\endfirsthead部分。

最后一点:threeparttable不适用于longtable。您必须加载threepartablex并使用ThreePartTable环境才能获得相同的功能,但语法略有不同。

\documentclass[12pt]{article}
\usepackage[showframe]{geometry}
\usepackage{lscape}
\usepackage{makecell, booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage{threeparttablex}

\begin{document}

 \begin{landscape}
\setlength{\tabcolsep}{3.5pt}
\sisetup{table-format=-1.3, table-number-alignment=center}
\small
\null\vfill
\begin{ThreePartTable}
    \begin{longtable}{l*{11}{S}}
    \caption{Cross-correlation table\label{corrtable}}\\
     \toprule\midrule
    \multicolumn{1}{c}{Variables} &{ Investments} & {\makecell{Cross-\\border}} & {Domestic} & {Early} & {GDP} & { \makecell{Market\\ Cap.}} &{ CPI} & {PRS} & {AS} & {IPO} & {Sales}\\
\midrule
    \endfirsthead
    \multicolumn{12}{l}{\emph{... table \thetable{} continued}}
     \\ \toprule
    \multicolumn{1}{c}{Variables} &{ Investments} & {\makecell{Cross-\\border}} & {Domestic} & {Early} & {GDP} & { \makecell{Market\\ Cap.}} &{ CPI} & {PRS} & {AS} & {IPO} & {Sales}\\
\midrule
    \endhead
    \midrule
    \multicolumn{12}{r}{\emph{Continued on next page...}}\\
    \endfoot
    \midrule\bottomrule
    \endlastfoot
   Investments & 1.000\\
    Cross-border & 0.885 & 1.000\\
    Domestic & 0.571 & 0.122 & 1.000\\
    Early & 0.758 & 0.849 & 0.118 & 1.000\\
    GDP & 0.168 & 0.073 & 0.230 & 0.072 & 1.000\\
    Market Cap. & 0.012 & -0.019 & 0.059 & 0.013 & -0.182 & 1.000\\
    CPI & 0.195 & 0.107 & 0.227 & 0.088 & 0.096 & 0.008 & 1.000\\
    PRS & 0.133 & 0.099 & 0.110 & 0.102 & 0.088 & -0.085 & 0.695 & 1.000\\
    AS & -0.201 & -0.074 & -0.298 & -0.028 & -0.172 & -0.072 & -0.522 & -0.442 & 1.000\\
    IPO & 0.077 & -0.038 & 0.231 & 0.004 & 0.038 & 0.131 & 0.178 & 0.020 & -0.011 & 1.000\\
    Sales & 0.126 & 0.060 & 0.163 & -0.001 & 0.139 & -0.175 & 0.373 & 0.312 & -0.379 & 0.026 & 1.000\\
    \end{longtable}
\end{ThreePartTable}
\vfill
 \end{landscape}

\end{document}

在此处输入图片描述

相关内容