3

For my thesis, I am trying to show the results of the cross-correlation analysis, but, due to the high number of variables, the table results to wide in any way I arrange it. I would like to know if there is a way for dividing it into two parts (possibly so that it stays on the same page).

Below you can find the code I got from 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}

P.S. I tried to set it on one side using (\landscape), but the last two columns are still not visible.

4

You don't need a longtable for this, because a twelve row table should never split across pages.

We can save space by avoiding to repeat the headers, adding numbers for them, which are also set for the rows.

Here are two versions that fit the standard text width, one in reduced font size, the other one rotated.

\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}

enter image description here

  • Thank you so much! Now it makes so much more sense :) – Chiara May 21 '18 at 11:41
1

It can fit the text height (landscape mode) if

  • you load geometry to have more decent margins,
  • play with the font size and the intercolumn space,
  • use makecell to have multiline column heads.

Here is a code with various improvements: using siunitx for the formatting and alignment of numbers, the rules from booktabs for a more professional look (in particuler, they add some vertical padding.O reorganised the code so tat the column heads come into the \endhead/\endfirsthead sections.

Last point: threeparttable doesn't work with longtable. You have to loaad threepartablex and use the ThreePartTable environment to have the same functionality, with a slightly different syntax.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.