0

I am trying to create a table in a landscape environment containing several subtables which content exceeds one page. Therefore a pagebreak within the table to separate the subtables on multiple pages is necessary.

The main problem here is that I can't use a longtable environment.

I've been using the table environment and putting tabulars inside, but the table environment isn't pagebreaking even using the \ContinuedFloat command.

I've tried using a figure environment and putting tabulars inside, but the figure environment isn't pagebreaking even using the \ContinuedFloat command,

\documentclass{scrartcl}

\usepackage[english,ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{subfig}
\usepackage{lscape}
\usepackage{float}
\usepackage{booktabs}
\usepackage{ltxtable}   
\usepackage{tabularx}


\newcolumntype{M}[1]{>{\centering}m{#1}}
\captionsetup[table]{position=top}
\captionsetup[subtable]{position=top}


\begin{document}

        \begin{landscape}
        \begin{table}[H] 
            \centering
            \caption{caption}
            \label{tab:1}
            %1  
            \subfloat[subcaption]{
                \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}| c| }
                    \hline
                    & a & b & c & d & e                                                                 \\ \hline               
                    i                                       & $5$ & $2$ & $2$ & $5$ & $3,2$ \tabularnewline \hline
                    ii                                      & $3$ & $3$ & $3$ & $2$ & $2,3$ \tabularnewline \hline
                \end{tabular}   }
            \subref{tab:a} 
            \qquad  
            %2          
            \subfloat[subcaption2]{
                \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}| c| }
                    \hline
                    & f & g & h & i & j \tabularnewline \hline

                    i       & $4$ & $3$ & $3$ & $3$ & $2,125$ \tabularnewline \hline
                    ii      & $4$ & $4$ & $5$ & $4$ & $2,8$ \tabularnewline \hline
            \end{tabular}   }
            \subref{tab:b} 

        \end{table}     

        \qquad

        \begin{table}[H]
            \centering
            \ContinuedFloat
            \addtocounter{table}{0}
            \caption{caption (continued)}
            \label{tab:1_continued}
            %6
            \subfloat[subcaption3]{
                \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}|c|}
                    \hline
                    & k & l & m & n & o \tabularnewline \hline

                    i                   & $5$ & $5$ & $5$ & $5$ & $3,75$  \tabularnewline \hline
                    ii                  & $4$ & $3$ & $3$ & $3$ & $2,5$ \tabularnewline \hline
                \end{tabular}   }
            \subref{tab:c}

            \qquad

            \subfloat[subcaption4]{
                \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}|c|}
                    \hline
                    & p & q & r & s & t \tabularnewline \hline

                    i       & $5$ & $5$ & $5$ & $5$ & $3,75$ \tabularnewline \hline
                    ii      & $5$ & $5$ & $3$ & $3$ & $3,15$ \tabularnewline \hline
                    iii     & $3$ & $3$ & $5$ & $5$ & $2,85$ \tabularnewline \hline
            \end{tabular}   }
            \subref{tab:d}

        \end{table}

        random ref \ref{tab:c}

    \end{landscape}
\end{document}

using \newline or \\ between the tabulars gives me:

"There's no line here to end. \newline"

This is what it looks like:

in what ever I've tried so far.

Im4X
  • 3
  • Welcome to TeX.SE! Please extend your code snippet to complete small document beginning with \documentclass, followed by preamble with necessary packages and your definitions, document body with your tables and ending with \end{document} – Zarko Jun 06 '19 at 11:39
  • 1
    See if https://tex.stackexchange.com/questions/278727/split-subfigures-over-multiple-pages/278748#278748 is what you looking for. \ContinuedFloat doesnt break float environments, it just preserve caption numbering in successive floats (when used correctly). – Zarko Jun 06 '19 at 11:48
  • Thanks for the hint. It's actually close to what i was looking for, but I am getting bothered by questionmarks next to the subtables and in references, even after compiling for quite some time. Any suggestions? – Im4X Jun 06 '19 at 12:21
  • you not defined labels on which you refer with \subref{tab:1}. However, please first fix your document example. It can not be compiled due to missing packages and errors in preamble as well in document body. Please, make it compilable. – Zarko Jun 06 '19 at 12:28
  • Sorry, Ive missed 2 packages, but built u a completely new file with the same questionmark errors that is atleast for me compilable – Im4X Jun 06 '19 at 12:51
  • 1
    See my answer below. At writing of LaTeX document you should be very careful. Each typing error in used commands stop compilation and you case make your question unclear (what actually is your problem) – Zarko Jun 06 '19 at 13:00
  • Well, you are right and im sorry. Thnaks for still being here!

    My problem at first was to pagebreak a table. Due to my misunderstanding of \ContinuedFloating i was unable to do so. After splitting my table into 3 tables, i was finally able to do so. Keeping the tablecounter from adding up, i was even able to keep it visually to 1 table.

    my problem atm is the reference. When refering to subfloates i keep getting questionmakrs and even the subtables contain questionmarks in the same line as the subcaption..

    – Im4X Jun 06 '19 at 13:08

2 Answers2

1
  • The code, which you provide, is not possible to test. Missed is type of document class, it has typing errors in document preamble, also it has errors in document body, where are missed \end{landscape}s. Please always test document example (MWE: Minimal Working Example) before you upload here, if it can be compiled and eliminate all found typing errors.
  • As I mentioned in comments, the command \ContinuedFloat is used that float caption, where it is used, has the same number as in the previous the same type of float. Your use seems to be wrong, since you haven't floats of the same type before floats, where you use it. Consequently your captions looks like :

enter image description here

  • It seems that you confuse the function of \label and \ref or subref. Later two are used for referring something with label, which indicate the last used referable counters (as are table, figure, section etc). If you like to have this functionality, you need first to insert labels after such counters. For example,: \section{...}\label{sec:my section} and the refer it as for example See section \ref{sec:my section}. In your case you need add labels after or in captions in subfloats and after float captions. See MWE below.
  • it is not clear, why in where you should use \\ in your code. For put some \subfloat below previous one, just insert empty lines between them.
\documentclass{article}
\usepackage{booktabs, ltxtable, tabularx}
\newcolumntype{M}[1]{>{\centering}m{#1}}
\usepackage{subfig}
\usepackage{pdflscape}

\begin{document}
    \begin{landscape}
\begin{table}[htb]
\centering
\subfloat[subcaption 1  \label{tab:1}]{
    \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}| c| }
    \hline
    & a & b & c & d & e \tabularnewline 
    \hline
    \end{tabular}   }

\subfloat[subcaption 2  {tab:2}]{
    \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}| c| }
    \hline
    & a & b & c & d & e \tabularnewline
    \hline
    \end{tabular}   }

\caption{overall-caption for the first part of image}
\label{tab:label}
\end{table}

\newpage % For put next "table" on the next page. In the real document it should be removed
\begin{table}[htb]
    \centering
    \ContinuedFloat
\subfloat[subcaption 3  \label{tab:3}]{
    \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}| c| }
    \hline
    & a & b & c & d & e \tabularnewline
    \hline
    \end{tabular}   }

\subfloat[subcaption 4  \label{tab:4}]{
    \begin{tabular}{|M{3cm}|M{3cm}|M{3cm}|M{3cm}|M{3cm}| c| }
    \hline
    & a & b & c & d & e \tabularnewline
    \hline
    \end{tabular}   }
\caption{overall-caption}
\label{tab:label}
\end{table}
\end{landscape}

See table \ref{tab:label}, particularly its subtables \ref{tab:4}, \ref{tab:4}, \ref{tab:4} and \ref{tab:4} \dots
\end{document}

which gives:

enter image description here

enter image description here

enter image description here

Zarko
  • 296,517
  • @Im4X, in my answer i didn't consider your last edit of question, since I finished it before it. – Zarko Jun 06 '19 at 13:07
0

Thanks to @Zarko I got to understand the \ContinuedFloat command and build several table envirnonments with tabulars that keep counting up (alphabetical) using the \ContinuedFloat command and stoped the tables from counting up using \addtocounter[table]{0}. To refer to subfloats, I am using \label instead of \subref due to some questionmark errors I still don't undestand.

Im4X
  • 3