1

I have a table whose text is unfortunately a bit longer and does not fit on one page. For this reason I would like to repeat the table on the second page.

I looked at Tabularx: Break long tables over several pages It does not work. The text is still only on one page. How can I make the table repeat itself on the second page?

Also the problem is the hyphenation and spacing. As can be seen here, the text was set with syllables although there was still plenty of space.

enter image description here

\documentclass[12pt]{report}
\usepackage[usegeometry]{typearea}% load before geometry
\usepackage[a4paper, left={2.5cm}, right={2cm}, top={3cm}, bottom={3cm}, headheight=15pt]{geometry}
\usepackage{tabularx}
% \renewcommand\tabularxcolumn[1]{m{#1}} % for vertical centering text in X column %-----> commented
\usepackage{caption}
\usepackage{pdflscape}
\captionsetup[table]{position=bottom}

\usepackage{fancyhdr} \fancypagestyle{plain}{% \fancyhf{}% \fancyhead[L]{\nouppercase{\leftmark}}% \fancyfoot[R]{\thepage}} \pagestyle{plain} \renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}} \usepackage[parfill]{parskip}

\usepackage{float} %----> added

\usepackage{tabularx} \usepackage{ltablex} \usepackage{ltablex}

\usepackage{longtable} \usepackage{lipsum} % just for dummy text- not needed for a longtable

\begin{document} \lipsum[1-6]

\begin{landscape}

\setlength{\tabcolsep}{0.5em} % for the horizontal padding {\renewcommand{\arraystretch}{1.2}% for the vertical padding \begin{table}[H] \caption[Name]{Überblick der Phasen des CRISP-DM Prozesses~\cite{PeterChapmanandJanetClintonandRandyKerberandTomKhabazaandThomasP.ReinartzandColinShe.2000}} \label{tab:crisp__ueberblick} \begin{tabularx}{\textwidth}{|X|X|X|X|X|X|} \hline %-----> added
\multicolumn{1}{|c|}{\textbf{BusinessUnderstanding}} & \multicolumn{1}{c|}{\textbf{Data Understanding}} & \multicolumn{1}{c|}{\textbf{Data Prepartion}} & \multicolumn{1}{c|}{\textbf{Modeling}} & \multicolumn{1}{c|}{\textbf{Evaluation}} & \multicolumn{1}{c|}{\textbf{Deployment}} \ \hline Geschäftsziele festlegen \newline Hintergrund \newline Unternehmensziele \newline Erfolgskriterien für das Unternehmen \newline

        Situation bewerten
        Bestandsaufnahme der Ressourcen
        Erfordernisse
        Annahmen und Beschränkungen
        Risiken und Zufälligkeiten
        Terminologie
        Kosten und Nutzen

        Bestimmen der Data-Mining-Ziele
        Data-Mining-Ziele
        Data Minig Erfolgskriterien

        Projektplan erstellen
        Projektplan
        Erste Bewertung von Tools und Techniken
        & This is another long text what a long text is that \newline And agian an new line
        & sad
        & asd 
        & aa
        & adasd                                    

        \\ \hline

    \end{tabularx}
\end{table}

} \end{landscape} \lipsum[1-6] \end{document}

with xltabular

\documentclass[12pt]{report}
\usepackage[usegeometry]{typearea}% load before geometry
\usepackage[a4paper, left={2.5cm}, right={2cm}, top={3cm}, bottom={3cm}, headheight=15pt]{geometry}
\usepackage{tabularx}
% \renewcommand\tabularxcolumn[1]{m{#1}} % for vertical centering text in X column %-----> commented
\usepackage{caption}
\usepackage{pdflscape}
\captionsetup[table]{position=bottom}

\usepackage{fancyhdr} \fancypagestyle{plain}{% \fancyhf{}% \fancyhead[L]{\nouppercase{\leftmark}}% \fancyfoot[R]{\thepage}} \pagestyle{plain} \renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}} \usepackage[parfill]{parskip} \usepackage{xltabular} \usepackage{float} %----> added

\usepackage{lipsum} % just for dummy text- not needed for a longtable

\begin{document} \lipsum[1-6]

\begin{landscape}

\setlength{\tabcolsep}{0.5em} % for the horizontal padding {\renewcommand{\arraystretch}{1.2}% for the vertical padding \begin{table}[H] \caption[Name]{Überblick der Phasen des CRISP-DM Prozesses~\cite{PeterChapmanandJanetClintonandRandyKerberandTomKhabazaandThomasP.ReinartzandColinShe.2000}} \label{tab:crisp__ueberblick} \begin{xltabular}{\textwidth}{|X|X|X|X|X|X|}

    \hline \multicolumn{1}{|c|}{\textbf{BusinessUnderstanding}} & \multicolumn{1}{c|}{\textbf{Data Understanding}} & \multicolumn{1}{c|}{\textbf{Data Prepartion}} & \multicolumn{1}{c|}{\textbf{Modeling}} & \multicolumn{1}{c|}{\textbf{Evaluation}} & \multicolumn{1}{c|}{\textbf{Deployment}} 
    \endfirsthead

    \multicolumn{6}{c}%
    {\tablename\ \thetable{}: -- continued from previous page} \\
    \hline \multicolumn{1}{|c|}{\textbf{BusinessUnderstanding}} & \multicolumn{1}{c|}{\textbf{Data Understanding}} & \multicolumn{1}{c|}{\textbf{Data Prepartion}} & \multicolumn{1}{c|}{\textbf{Modeling}} & \multicolumn{1}{c|}{\textbf{Evaluation}} & \multicolumn{1}{c|}{\textbf{Deployment}} 
    \endhead

    \multicolumn{6}{|r|}{{Continued on next page...}} \\
    \endfoot

    \hline
    \endlastfoot

        Geschäftsziele festlegen \newline
        Hintergrund \newline 
        Unternehmensziele \newline
        Erfolgskriterien für das Unternehmen \newline

        Situation bewerten
        Bestandsaufnahme der Ressourcen
        Erfordernisse
        Annahmen und Beschränkungen
        Risiken und Zufälligkeiten
        Terminologie
        Kosten und Nutzen

        Bestimmen der Data-Mining-Ziele
        Data-Mining-Ziele
        Data Minig Erfolgskriterien

        Projektplan erstellen
        Projektplan
        Erste Bewertung von Tools und Techniken
        & This is another long text what a long text is that \newline And agian an new line
        & sad
        & asd 
        & aa
        & adasd                                    

        \\ \hline

    \end{xltabular}
\end{table}

} \end{landscape} \lipsum[1-6] \end{document}

Test
  • 179
  • 2
    Did you try with xltabular, which brings the functionalities of longtable to tabularx? – Bernard Jun 05 '22 at 15:52
  • @Bernard thank you for your hint. Yes I tried xltabular I changed \begin{tabularx} to \begin{xltabular}. Maybe I did it wrong too. – Test Jun 05 '22 at 15:54
  • 1
    You have to use longtable syntax (endhead, \endfirsthead, &c.). This being said, you can break a longtable within a cell – only between rows. – Bernard Jun 05 '22 at 15:57
  • @Bernard thanks for the hint! I understand. I have not received my desired output because I am doing something wrong. Please see my edit. – Test Jun 05 '22 at 16:14
  • 1
    you didn't take into account that a longtable (or xltabular) cannot break page within a cell, so, in my opinion, you should redesign your table to ensure it will have page breaks between rows. – Bernard Jun 05 '22 at 17:41
  • 1
    So far showed MWE is duplicate to your previous question: https://tex.stackexchange.com/questions/646707/create-table-design. if now have problem how to write a long table, I expect that you will start with code from accepted answer on previous question and in tan table body repeat rows as many time as needed that tble protrude bottom of page. – Zarko Jun 05 '22 at 19:14
  • The main problem is putting longtable or xltabular inside a table environment. The table environment is not needed for these and will not break across pages. – John Kormylo Jun 05 '22 at 22:55

1 Answers1

2

An example of long table using longtblr table dafined in tabularray package:

enter image description here

\documentclass[12pt]{report}

\usepackage[usegeometry]{typearea} \usepackage[margin=25mm]{geometry} \usepackage{pdflscape} \usepackage{microtype}

\usepackage{tabularray} \UseTblrLibrary{booktabs}

\usepackage{lipsum}

\begin{document} \begin{landscape}

\begin{longtblr}[ caption = {Überblick der Phasen des CRISP-DM Prozesses \cite{PeterChapmanandJanetClintonandRandyKerberandTomKhabazaandThomasP.ReinartzandColinShe.2000}}, entry = name, label = {tab:crisp__ueberblick}, ]{ hlines, vlines, colspec = {*{6}{X[j, font=\small]}}, row{1} = {font=\bfseries, c, m}, rowhead = 1} Business Understanding & Data Understanding & Data Prepartion & Modeling & Evaluation & Deployment \ \lipsum[66] & \lipsum[66] & sad & asd & aa & adasd \ \lipsum[65] & \lipsum[66] & sad & asd & aa & adasd \

\end{longtblr}

\end{landscape} \lipsum[1-3] \end{document}

From your MWE can be concluded that long text are only in the first two columns. I this is true, than you may consider to make this two columns wider and rest narrower. In longtblr this can be simple done by defining columns widths ratios. For example:

    colspec = {*{2}{X[1.2, j, font=\small]}
               *{4}{X[0.9, j, font=\small]} },

In this case table looks is :

enter image description here

Addednum: As mentioned @ barbara beeton in her comment (I I totally agree with her), text in narrow columns is easier to read if it were set ragged right. This is simple to so. Just replace option j (justified) by option l (left aligned). For example, when in the same time make first two columns even wider,:

    colspec = {*{2}{X[2, l, font=\small]}
               *{4}{X[1, l, font=\small]} },

enter image description here

Zarko
  • 296,517
  • The text in the first two columns would be easier to read if it were set ragged right. – barbara beeton Jun 05 '22 at 19:41
  • @barbarabeeton, columns are quite narrow, so you are right, in them adjusted text is more difficult to read. To make ragged right text is simple: option j let replace l. However, there may be more place to make first two column wider and in both cases will reading text in them be easier. I will Add example with ragged right text ASAP – Zarko Jun 05 '22 at 19:59