0

Have a long table that I want to split in several pages, or, alternatively, break into two within the same page. I am quite new to LaTeX, so struggling a little to make longtable work

\begin{threeparttable}[!htbp] \centering 
  \caption{Descriptive Statistics: Nationality} 
  \label{tab:Table7} 
\scriptsize 
\begin{tabular}[t]{@{\extracolsep{1pt}}lcc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{3}{c}{\textit{Treatment}} \\ 
\cline{2-4} 
\\[-1.8ex] & Frequency & Percentage \\ 
\hline \\[-1.8ex] 
 Argentina & $10$ & $0.36$ \\ 
 & & \\
  Armenia & $1$ & $0.04$ \\ 
 & &  \\
  Australia & $43$ & $1.96$ \\ 
 & &  \\
  Austria & $22$ & $0.80$ \\ 
 & & \\
  Belgium & $21$ & $0.76$ \\ 
 & &  \\
  Bermuda & $1$ & $0.04$\\
  & & \\
  Bolivia & $1$ & $0.04$ \\
 & & \\
 Brazil & $41$ & $1.49$ \\
 & & \\
  Bulgaria & $1$ & $.04$ \\ 
 & &  \\
 Cameroon & $1$ & $0.04$ \\ 
 & &  \\
 Canada & $86$ & $3.12$ \\ 
 & & \\
   Chile & $13$ & $0.47$ \\ 
 & & \\
  China & $14$ & $0.51$  \\ 
 & &  \\
  Colombia & $18$ & $0.65$ \\ 
 & &  \\
  Costa Rica & $2$ & $0.07$ \\ 
 & &  \\
  Croatia & $1$ & $0.04$ \\ 
 & &  \\
  Cuba & $2$ & $0.07$ \\ 
 & & \\
  Czech Republic & $3$ & $0.11$ \\ 
 & & \\
  Denmark & $15$ & $0.55$  \\ 
 & & \\
  Ecuador & $440$ & $15.99$ \\ 
 & & \\
  Egypt & $2$ & $0.07$ \\ 
 & & \\
 England & $162$ & $5.89$ \\ 
 & & \\
  Estonia & $3$ & $0.11$  \\ 
 & & \\
  *Europe & $8$ & $0.29$  \\ 
 & & \\
  Finland & $7$ & $0.25$  \\ 
 & & \\
  France & $46$ & $1.67$  \\ 
  & & \\
  French Polynesia & $1$ & $0.04$ \\ 
 & & \\
  Germany & $162$ & $5.89$ \\ 
 & & \\
  Greece & $5$ & $0.18$  \\ 
 & & \\
  Guatemala & $1$ & $0.04$  \\ 
 & & \\
  Hungary & $1$ & $0.04$ \\ 
 & & \\
  India & $16$ & $0.58$  \\ 
 & & \\
  Indonesia & $3$ & $0.11$ \\ 
 & & \\
  Iran & $1$ & $0.04$  \\ 
 & & \\
  Ireland & $8$ & $0.29$ \\ 
 & & \\
  Israel & $7$ & $0.25$  \\ 
 & & \\
  Italy & $52$ & $1.89$ \\ 
 & & \\
  Japan & $8$ & $0.29$  \\ 
 & & \\
  Kenya & $1$ & $0.04$  \\ 
 & & \\
  Kosovo & $1$ & $0.04$  \\ 
 & & \\

%figure out how to use longtable format here and split it.

Lebanon & $1$ & $0.04$ \ & & \ Lithuania & $1$ & $0.04$ \ & & \ Luxembourg & $2$ & $0.07$ \ & & \ Malta & $1$ & $0.04$ \ & & \ Mauritius & $1$ & $0.04$ \
& & \ Mexico & $18$ & $0.65$ \ & & \ Monaco & $1$ & $0.04$ \ & & \ Morocco & $1$ & $0.04$ \ & & \ *Multi National & $8$ & $0.29$ \ & & \ Netherlands & $57$ & $2.07$ \ & & \ New Zealand & $10$ & $0.36$ \ & & \ Nigeria & $1$ & $0.04$ \ & & \ Norway & $7$ & $0.25$ \ & & \ Pakistan & $1$ & $0.04$ \ & & \ Panama & $2$ & $0.07$ \ & & \ Peru & $6$ & $0.22$ \ & & \ Philippines & $3$ & $0.11$ \ & & \ Poland & $12$ & $0.44$ \ & & \ Portugal & $13$ & $0.47$ \ & & \ Puerto Rico & $1$ & $0.04$ \ & & \ Romania & $2$ & $0.07$ \ & & \ Russia & $3$ & $0.11$ \ & & \ Saudi Arabia & $1$ & $0.04$ \ & & \ Scotland & $1$ & $0.04$ \ & & \ Serbia & $2$ & $0.07$ \ & & \ Singapore & $4$ & $0.15$ \ & & \ Slovakia & $1$ & $0.04$ \ & & \ Slovenia & $2$ & $0.07$ \ & & \ Somalia & $1$ & $0.04$ \ & & \ South Africa & $6$ & $0.22$ \ & & \ South Korea & $7$ & $0.25$ \ & & \ Spain & $262$ & $9.52$ \ & & \ Sweden & $16$ & $0.58$ \ & & \ Switzerland & $42$ & $1.53$ \ & & \ Taiwan & $4$ & $0.15$ \ & & \ Turkey & $2$ & $0.07$ \ & & \ USA & $1,003$ & $36.45$ \ & & \ Ukraine & $5$ & $0.18$ \ & & \ Uruguay & $2$ & $0.07$ \ & & \ Venezuela & $8$ & $0.29$ \ & & \

\hline \[-1.8ex] Total & 2,752 & 100.00 \ & & & \ %Chi-Sqd & 68.4043 \ %P-value & 0.797 \ \hline \hline \[-1.8ex] %\textit{Note: } \ \end{tabular} \begin{tablenotes} \footnotesize \item \textit{Note: %Where the H$_0$ for the chi-square test of independence states that the two groups are independent. When the p-value (shown above in parentheses) is not less than p=0.05, the H$_0$ fails to be rejected. That is, there is insufficient evidence that an association exists between the treatment grouping and a given variable. } \end{tablenotes}

\end{threeparttable}

Sorry for repeated question,

Dai Bowen
  • 6,117

2 Answers2

0

in order to split a table into several pages you could use longtable package.

\usepackage{longtable}

...

\begin{center} \begin{longtable}{p{.1\textline} | p{.3\textline} | p{.3\textline} | p{.3\textline}} \caption{A sample long table.} \label{tab:long} \

\hline \multicolumn{1}{|c|}{\textbf{Main Idea}} & \multicolumn{1}{c|}{\textbf{Source 1}} & \multicolumn{1}{c|}{\textbf{Source 2}} & \multicolumn{1}{c|}{\textbf{Source 3}} \ \hline \endfirsthead

\multicolumn{4}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \ \hline \multicolumn{1}{|c|}{\textbf{Main Idea}} & \multicolumn{1}{c|}{\textbf{Source 1}} & \multicolumn{1}{c|}{\textbf{Source 2}} & \multicolumn{1}{c|}{\textbf{Source 3}} \

\hline \endhead

\hline \multicolumn{4}{|r|}{{Continued on next page}} \ \hline \endfoot

\hline \hline \endlastfoot

Zero & One & abcdef ghjijklmn & 123.456778 \ Zero & \small \lipsum[1] \normalsize & abcdef ghjijklmn & 123.456778 \ Zero & \small \lipsum[4] \normalsize & abcdef ghjijklmn & \small \lipsum[2] \normalsize \

\end{longtable} \end{center}

0
  • Probably to late for OP but may help to someone else ...
  • Your main problem is (apparently) to rewrite your table accordingly. This is your job, you can not expected that this instead of you will do someone else here.
  • To fit your table in one page, you have two possibilities:
    • as is suggested in other answer
    • split table into two parallel parts, i.e in the middle of existing table insert
\end{tabular}
\hfill
\begin{tabular}{...}
  • The second case, which require less work with table editing, doesn't work in threeparttable. Instead it you should use float table and write table notes as ordinary text below the second tabular.
  • Since table is quite large, You need in table to reduce
    • font size (to \small)
    • \tabcolsep, for example to 3p
    • \arraystretch, for example to 0.95 (see code fragment below)
  • For more professional look and better readable I suggest to use rules defined in booktabs package and inserted some vertical space after each ten rows (or more frequently if you liked):
\documentclass{article}

\usepackage[skip=1ex, font=small, labelfont=bf]{caption} \usepackage{booktabs} \usepackage{siunitx}

\begin{document} \begin{table}[ht] \caption{Descriptive Statistics Nationality. Treatment: Frequency and Percentage} \label{tab:Table7} \setlength\tabcolsep{3pt} \renewcommand\arraystretch{0.95} \small \begin{tabular}[t]{@{} lSS @{}} \toprule &{Frequency}&{Percentage} \ \midrule Argentina & 10 & 0.36 \ Armenia & 1 & 0.04 \ Lebanon & 1 & 0.04 \ Lithuania & 1 & 0.04 \ Australia & 43 & 1.96 \ Austria & 22 & 0.80 \ Belgium & 21 & 0.76 \ Bermuda & 1 & 0.04 \ Bolivia & 1 & 0.04 \ Brazil & 41 & 1.49 \

\addlinespace Bulgaria & 1 & 0.04 \ Cameroon & 1 & 0.04 \ % rest of first part table \addlinespace Japan & 8 & 0.29 \ Kenya & 1 & 0.04 \ \midrule[\heavyrulewidth] \end{tabular} \hfill \begin{tabular}[t]{@{} lS[table-format=4.0] S[table-format=3.2] @{}} \toprule &{Frequency}&{Percentage} \ \midrule Kosovo & 1 & 0.04 \ Lebanon & 1 & 0.04 \ Lithuania & 1 & 0.04 \ Luxembourg & 2 & 0.07 \ Malta & 1 & 0.04 \ Mauritius & 1 & 0.04 \ Mexico & 18 & 0.65 \ Monaco & 1 & 0.04 \ Morocco & 1 & 0.04 \ *Multi National & 8 & 0.29 \

\addlinespace Netherlands & 57 & 2.07 \ New Zealand & 10 & 0.36 \

\addlinespace Uruguay & 2 & 0.07 \ Venezuela & 8 & 0.29 \ \midrule[\heavyrulewidth] Total & 2 752 & 100.00 \ \bottomrule \end{tabular}

\medskip\footnotesize\itshape Note: Where the H$_0$ for the chi-square test of independence states that the two groups are independent. When the p-value (shown above in parentheses) is not less than p=0.05, the H$_0$ fails to be rejected. That is, there is insufficient evidence that an association exists between the treatment grouping and a given variable. \end{table} \end{document}

enter image description here

Zarko
  • 296,517