I'm trying to fit a landscape tabularx table over multiple pages, however with the solutions I've found, I'm not able to do so.
I've also picked up the solution for generating the table itself from another question which really fits my needs as long as I don't have too many rows. So therefore, I'd like to keep that solution (if possible) and just have it modified so that it can fit more rows and break it over several pages, if necessary.
Here's an MWE:
\documentclass[12pt,a4paper,bibtotoc,headsepline,smallheadings,oneside,appendixprefix,BCOR5mm]{scrbook}
\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{eurosym}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{exscale}
\usepackage{amstext}
\usepackage{bm}
\usepackage{caption}
\usepackage{mathtools}
\usepackage{array}
\usepackage{rotating}
\usepackage[ruled, english]{algorithm2e}
\usepackage{verbatim}
\usepackage{float}
\usepackage[section]{placeins}
\usepackage{color}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{pifont}
\newcommand*\rot{\rotatebox{90}}
\newcommand*\OK{\ding{51}}
\makeatletter
\newcommand*{\rom}[1]{\expandafter\@slowromancap\romannumeral #1@}
\usepackage{array,multirow}
\usepackage{subfigure}
\usepackage{setspace}
\usepackage[hyphens]{url}
\usepackage[plainpages=false,pdfpagelabels=true,colorlinks=true,linkcolor=black,citecolor=black,bookmarksopen=true]{hyperref}
\usepackage{scrpage2}
\usepackage{natbib}
\usepackage{mathtools}
\usepackage{apalike}
\usepackage{comment}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{geometry}
\usepackage{makecell}
\usepackage{tabularx,ragged2e}
\usepackage{pdflscape}
\usepackage{ltablex}
\definecolor{Gray}{gray}{0.8}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\usepackage[hang,flushmargin,perpage]{footmisc}
\renewcommand{\bibname}{References}
\renewcommand\theadalign{bc}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{\Gape[4pt]}
\renewcommand\cellgape{\Gape[4pt]}
\bibliographystyle{apalike}
\renewcommand{\topfraction}{0.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\floatpagefraction}{0.75}
\onehalfspacing
\definecolor{grey}{gray}{0.5}
\newcommand{\argmax}{\operatornamewithlimits{argmax}}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\newenvironment{conditions}
{\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}}
{\end{tabular}\par\vspace{\belowdisplayskip}}
\begin{document}
\pagestyle{empty}
\pagenumbering{alph}
\mainmatter
\begin{landscape}
\begin{table}[htp]
\footnotesize
\begin{tabularx}{\hsize}{|C|C|C|C|C|C|C|C|}
\hline
\textbf{Avg. F1 Training} & \textbf{Avg. F1 Validation} & \textbf{Avg. Recall Training} & \textbf{Avg. Recall Validation} & \textbf{Avg. Precision Training} & \textbf{Avg. Precision Validation} & \textbf{Gap between F1 Training \& Validation} \\
\hline
0.97& 0.91& 0.95& 0.88& 0.99& 0.95& 0.06\\
\hline
0.99& 0.94& 0.98& 0.91& 1.00& 0.96& 0.05\\ \hline
0.98& 0.93& 0.97& 0.90& 0.99& 0.95& 0.05\\ \hline
0.97& 0.92& 0.95& 0.89& 0.99& 0.95& 0.05\\ \hline
0.98& 0.93& 0.96& 0.91& 0.99& 0.95& 0.05\\ \hline
0.92& 0.87& 0.88& 0.82& 0.97& 0.94& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.95& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.97& 0.91& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.96& 0.91& 0.99& 0.95& 0.05\\ \hline
0.98& 0.93& 0.96& 0.91& 0.99& 0.95& 0.05\\ \hline
0.98& 0.93& 0.96& 0.91& 0.99& 0.95& 0.05\\ \hline
0.97& 0.92& 0.95& 0.89& 0.99& 0.96& 0.05\\ \hline
0.98& 0.93& 0.96& 0.91& 0.99& 0.95& 0.05\\ \hline
0.98& 0.93& 0.96& 0.91& 0.99& 0.96& 0.05\\ \hline
0.97& 0.93& 0.96& 0.91& 0.99& 0.95& 0.04\\ \hline
0.97& 0.93& 0.96& 0.91& 0.99& 0.95& 0.04\\ \hline
0.97& 0.93& 0.96& 0.91& 0.99& 0.96& 0.04\\ \hline
0.92& 0.88& 0.89& 0.83& 0.96& 0.93& 0.04\\ \hline
0.97& 0.93& 0.95& 0.90& 0.99& 0.95& 0.04\\ \hline
0.96& 0.92& 0.94& 0.89& 0.98& 0.95& 0.04\\ \hline
0.97& 0.92& 0.95& 0.90& 0.98& 0.95& 0.04\\ \hline
0.97& 0.93& 0.95& 0.90& 0.99& 0.95& 0.04\\ \hline
0.97& 0.93& 0.95& 0.90& 0.99& 0.95& 0.04\\ \hline
0.97& 0.93& 0.95& 0.90& 0.99& 0.95& 0.04\\ \hline
0.97& 0.93& 0.95& 0.91& 0.99& 0.96& 0.04\\ \hline
0.96& 0.92& 0.94& 0.90& 0.98& 0.94& 0.04\\ \hline
0.97& 0.93& 0.95& 0.91& 0.99& 0.96& 0.04\\ \hline
0.97& 0.93& 0.95& 0.90& 0.98& 0.95& 0.04\\ \hline
0.96& 0.93& 0.94& 0.90& 0.98& 0.95& 0.04\\ \hline
0.77& 0.73& 0.67& 0.63& 0.91& 0.88& 0.04\\ \hline
0.96& 0.92& 0.93& 0.89& 0.98& 0.95& 0.04\\ \hline
0.95& 0.92& 0.93& 0.89& 0.98& 0.95& 0.03\\ \hline
0.96& 0.93& 0.94& 0.90& 0.98& 0.95& 0.03\\ \hline
0.95& 0.92& 0.93& 0.89& 0.97& 0.95& 0.03\\ \hline
0.95& 0.92& 0.92& 0.88& 0.98& 0.95& 0.03\\ \hline
0.96& 0.92& 0.93& 0.90& 0.98& 0.95& 0.03\\ \hline
0.96& 0.92& 0.93& 0.90& 0.98& 0.95& 0.03\\ \hline
0.90& 0.87& 0.87& 0.83& 0.94& 0.92& 0.03\\ \hline
0.96& 0.93& 0.93& 0.90& 0.98& 0.96& 0.03\\ \hline
0.93& 0.90& 0.90& 0.86& 0.97& 0.95& 0.03\\ \hline
0.94& 0.91& 0.91& 0.88& 0.97& 0.95& 0.03\\ \hline
0.95& 0.93& 0.93& 0.90& 0.98& 0.95& 0.03\\ \hline
0.95& 0.92& 0.92& 0.89& 0.97& 0.95& 0.03\\ \hline
0.95& 0.92& 0.93& 0.90& 0.97& 0.94& 0.03\\ \hline
0.93& 0.90& 0.89& 0.86& 0.97& 0.95& 0.03\\ \hline
0.95& 0.92& 0.92& 0.90& 0.97& 0.95& 0.03\\ \hline
0.95& 0.92& 0.92& 0.89& 0.97& 0.95& 0.03\\ \hline
0.92& 0.89& 0.88& 0.85& 0.95& 0.93& 0.03\\ \hline
0.94& 0.92& 0.92& 0.89& 0.97& 0.95& 0.03\\ \hline
0.87& 0.84& 0.81& 0.78& 0.94& 0.92& 0.02\\ \hline
0.95& 0.92& 0.92& 0.90& 0.97& 0.95& 0.02\\ \hline
0.93& 0.90& 0.90& 0.87& 0.96& 0.94& 0.02\\ \hline
0.93& 0.91& 0.91& 0.88& 0.96& 0.94& 0.02\\ \hline
0.94& 0.91& 0.91& 0.89& 0.96& 0.94& 0.02\\ \hline
0.92& 0.90& 0.89& 0.87& 0.96& 0.94& 0.02\\ \hline
0.93& 0.91& 0.91& 0.89& 0.96& 0.94& 0.02\\ \hline
0.88& 0.87& 0.85& 0.82& 0.93& 0.91& 0.02\\ \hline
0.93& 0.91& 0.90& 0.88& 0.96& 0.94& 0.02\\ \hline
0.93& 0.91& 0.90& 0.88& 0.96& 0.95& 0.02\\ \hline
0.89& 0.87& 0.84& 0.82& 0.94& 0.93& 0.02\\ \hline
0.72& 0.70& 0.61& 0.59& 0.88& 0.86& 0.02\\ \hline
0.89& 0.87& 0.84& 0.82& 0.94& 0.93& 0.02\\ \hline
0.88& 0.86& 0.82& 0.81& 0.94& 0.93& 0.01\\ \hline
0.91& 0.90& 0.88& 0.86& 0.95& 0.93& 0.01\\ \hline
0.88& 0.87& 0.84& 0.82& 0.94& 0.93& 0.01\\ \hline
0.85& 0.84& 0.80& 0.78& 0.92& 0.91& 0.01\\ \hline
0.88& 0.87& 0.84& 0.83& 0.93& 0.92& 0.01\\ \hline
0.88& 0.87& 0.84& 0.83& 0.93& 0.92& 0.01\\ \hline
0.88& 0.86& 0.83& 0.82& 0.93& 0.92& 0.01\\ \hline
0.87& 0.86& 0.83& 0.81& 0.93& 0.92& 0.01\\ \hline
0.84& 0.83& 0.78& 0.77& 0.91& 0.90& 0.01\\ \hline
0.75& 0.74& 0.70& 0.69& 0.82& 0.81& 0.01\\ \hline
0.74& 0.74& 0.67& 0.67& 0.84& 0.83& 0.01\\ \hline
0.79& 0.78& 0.72& 0.71& 0.87& 0.86& 0.01\\ \hline
0.78& 0.78& 0.71& 0.70& 0.88& 0.88& 0.01\\ \hline
0.75& 0.75& 0.66& 0.66& 0.88& 0.88& 0.00\\ \hline
0.74& 0.73& 0.65& 0.65& 0.85& 0.85& 0.00\\ \hline
0.62& 0.62& 0.54& 0.54& 0.73& 0.73& 0.00\\ \hline
0.74& 0.74& 0.65& 0.65& 0.86& 0.86& 0.00\\ \hline
0.70& 0.70& 0.61& 0.61& 0.82& 0.82& 0.00\\ \hline
0.63& 0.63& 0.54& 0.54& 0.76& 0.76& 0.00\\ \hline
0.63& 0.63& 0.55& 0.55& 0.73& 0.73& 0.00\\ \hline
0.62& 0.62& 0.55& 0.55& 0.70& 0.70& 0.00\\ \hline
0.68& 0.68& 0.60& 0.60& 0.77& 0.77& 0.00\\ \hline
0.65& 0.65& 0.55& 0.55& 0.79& 0.79& 0.00\\ \hline
0.64& 0.64& 0.54& 0.54& 0.78& 0.78& 0.00\\ \hline
0.69& 0.69& 0.60& 0.60& 0.82& 0.82& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
0.00& 0.00& 0.00& 0.00& 0.00& 0.00& 0.00\\ \hline
\end{tabularx}
\caption{caption.}
\end{table}
\end{landscape}
\end{document}
I tried to use the longtable command before the tabularx environment or using the ltablex package but nothing seems to work. Any advice is very welcome!
Best Answer
I'd suggest the following layout based on
longtable
andbooktabs
. With some abbreviations in the column headers there is no need to use\footnotesize
d text or to turn the table to landscape. I have also removed all vertical lines and replaced the horizontal lines by lines and some vertical white spaces from thebooktabs
package that you already load. I have also made use of the\endhead
and\endfirsthead
commands from thelongtable
package in order to repeat column headers on all pages.