Graphics, Figures & TablesProblems with page break on landscape multi-page table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
AstridH
Posts: 6
Joined: Mon Dec 02, 2013 2:03 pm

Problems with page break on landscape multi-page table

Post by AstridH »

Hello,

I would like to create a multi-page table in landscape format. To create the multi-page table I'm currenly using the ltablex package, i.e. the tabularx environment, embedded in a sidewaystable environment. At the moment this combination seem to ignore page breaks and thus my table is overfloating set page boundaries.

The documentation on ltablex is rather slim and I was wondering if someone might know if the ltablex and rotating packages are overwriting or excluding each other, as the table breaks without problems over several pages when not included in the sidewaystable environment.
If this should be the case, do you have possible suggestions of how to get around this problem as the size of the table requires it to be in landscape format.

I searched quite a bit online and am aware of the tabu package. Unfortunately I was unable to install it. If this should be the only recommended solution I will open another thread for my tabu installation problem. I, however, hope that there is a solution to be found using ltablex.

Many thanks,
Astrid

Code: Select all

\documentclass[a4paper, 12pt]{report}

\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{array}
\usepackage{multirow}
\usepackage{longtable}


\begin{document}


\begin{sidewaystable}[htb]
\begin{tabularx}{\textwidth}{X p{0.8cm}p{0.8cm}p{0.8cm}p{0.8cm}p{1.6cm}p{1.6cm}p{1.6cm}p{0.8cm}p{0.8cm}p{0.8cm}p{0.8cm}}
\caption{This should become a very long multi-page table.}\\
    \toprule
                            & \multicolumn{11}{l}{Something}\\
                            & \multicolumn{5}{l}{\textit{xxxxx}}        & \multicolumn{6}{l}{\textit{xxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
                            & \multicolumn{11}{l}{Something}\\
                            &\multicolumn{5}{l}{\textit{xxxxx}}  & \multicolumn{6}{l}{\textit{xxxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
    \multirow{2}{*}{Taxa}   & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X} & X & X & X & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X}\\
                            \cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-6} \cmidrule(r){7-7} \cmidrule(r){8-8} \cmidrule(r){9-10}  \cmidrule(r){11-12}
                            & 1 & 2     &1 & 2      &      &   &      &1 &2    &1 &2  \\
    \toprule
\endfirsthead
    \caption{some sort of caption. (continued)}\\
     \toprule
                            & \multicolumn{11}{l}{Something}\\
                            & \multicolumn{5}{l}{\textit{xxxxx}}        & \multicolumn{6}{l}{\textit{xxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
                            & \multicolumn{11}{l}{Something}\\
                            &\multicolumn{5}{l}{\textit{xxxxx}}  & \multicolumn{6}{l}{\textit{xxxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
    \multirow{2}{*}{Taxa}   & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X} & X & X & X & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X}\\
                            \cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-6} \cmidrule(r){7-7} \cmidrule(r){8-8} \cmidrule(r){9-10}  \cmidrule(r){11-12}
                            & 1 & 2     &1 & 2      &      &   &      &1 &2    &1 &2  \\
    \toprule
\endhead
     \bottomrule
     \multicolumn{2}{l}{{Continued on Next Page\ldots}}     \\
     \bottomrule
\endfoot
    \bottomrule
\endlastfoot
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\ \cmidrule(r){1-1}
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\ \cmidrule(r){1-1}
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\ \cmidrule(r){1-1}
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\end{tabularx}
\end{sidewaystable}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

AstridH
Posts: 6
Joined: Mon Dec 02, 2013 2:03 pm

Problems with page break on landscape multi-page table

Post by AstridH »

Hello!

I found a solution online after having read this post:
http://tex.stackexchange.com/questions/ ... ble-method

I simply replaced the ltablex package with the ltxtable package and the rotation package with the pdflscape package. I then created a new .tex file for the longtable and embedded it in the \LTXtable environment in my main document and it runs without problems.

Code looks now like this:
Main document:

Code: Select all

\usepackage{ltxtable}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{array}
\usepackage{multirow}
\usepackage{longtable}


\begin{document}

\begin{landscape}
\small
\LTXtable{\textwidth}{input_table.tex}
\end{landscape}

\end{document}
External table file:

Code: Select all

\begin{longtable}{p{4.5cm} p{0.8cm}p{0.8cm}p{0.8cm}p{0.8cm}p{1.6cm}p{1.6cm}p{1.6cm}p{0.8cm}p{0.8cm}p{0.8cm}p{0.8cm}}
\caption{This should become a very long multi-page table.}\\
    \toprule
                            & \multicolumn{11}{l}{Something}\\
                            & \multicolumn{5}{l}{\textit{xxxxx}}        & \multicolumn{6}{l}{\textit{xxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
                            & \multicolumn{11}{l}{Something}\\
                            &\multicolumn{5}{l}{\textit{xxxxx}}  & \multicolumn{6}{l}{\textit{xxxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
    \multirow{2}{*}{Taxa}   & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X} & X & X & X & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X}\\
                            \cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-6} \cmidrule(r){7-7} \cmidrule(r){8-8} \cmidrule(r){9-10}  \cmidrule(r){11-12}
                            & 1 & 2     &1 & 2      &      &   &      &1 &2    &1 &2  \\
    \toprule
\endfirsthead
    \caption{some sort of caption. (continued)}\\
     \toprule
                            & \multicolumn{11}{l}{Something}\\
                            & \multicolumn{5}{l}{\textit{xxxxx}}        & \multicolumn{6}{l}{\textit{xxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
                            & \multicolumn{11}{l}{Something}\\
                            &\multicolumn{5}{l}{\textit{xxxxx}}  & \multicolumn{6}{l}{\textit{xxxxxx}}\\ \cmidrule(r){2-6} \cmidrule(r){7-12}
    \multirow{2}{*}{Taxa}   & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X} & X & X & X & \multicolumn{2}{l}{X} & \multicolumn{2}{l}{X}\\
                            \cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-6} \cmidrule(r){7-7} \cmidrule(r){8-8} \cmidrule(r){9-10}  \cmidrule(r){11-12}
                            & 1 & 2     &1 & 2      &      &   &      &1 &2    &1 &2  \\
    \toprule
\endhead
     \bottomrule
     \multicolumn{2}{l}{{Continued on Next Page\ldots}}     \\
     \bottomrule
\endfoot
    \bottomrule
\endlastfoot
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\ \cmidrule(r){1-1}
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\ \cmidrule(r){1-1}
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\ \cmidrule(r){1-1}
\textit{A very long species name}               &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   &0   \\
\end{longtable}
Maybe this solution will help someone else with a similar problem.

Cheers,
Astrid
Post Reply