[Tex/LaTex] Longtable – How to use it within a table environment

longtabletables

I have the following latex code. My issue is that the table below does not fit the page. I would like to break the table on the "Panel C" row but I couldn't figure out how to do it while keeping the title and caption.

I tried the longtable package with no success.

\documentclass[12pt,a4paper]{article}
    \usepackage{geometry}
    \usepackage[font=small,labelfont=bf,margin=\parindent,tableposition=top]{caption}
    \usepackage{longtable}
 \geometry{
 a4paper,
 total={210mm,297mm},
 left=20mm,
 right=20mm,
 top=23mm,
 bottom=30mm,
 }
\begin{document}
\begin{table}[!htbp]                            
      \centering                            
      \caption{Title ...}
      \caption*{Some description here } 
      \begin{tabular}{llcccc}
    \hline
    \multicolumn{6}{c}{Panel A:}                                                                                        \\ \hline
          &  & Dummy                     &                      & Dummy                     & Dummy                     \\ \cline{3-3} \cline{5-6} 
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\ \hline
    \multicolumn{6}{c}{Panel B}                                                                                         \\ \hline
          &  & \multicolumn{1}{l}{Dummy} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{Dummy} & \multicolumn{1}{l}{Dummy} \\ \cline{3-3} \cline{5-6} 
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\ \hline
    \multicolumn{6}{c}{Panel C}                                                                                         \\ \hline
          &  & Dummy                     &                      & Dummy                     & Dummy                     \\ \cline{3-3} \cline{5-6} 
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\ \hline
    \end{tabular}


    \end{table}%
\end{document}

Best Answer

Since longtable is meant for pagebreaking, a floating table feature is not really useful here.

longtable is basically used like tabular, with column descriptions, additionally it allows for \caption inside of the longtable environment.

Page breaks can be forced with an 'ordinary' \newpage or prevented with \nopagebreak or \\*

I've used \newpage right before the Panel C table.

Since there's no real table header, I've omitted \endfirsthead etc.

\documentclass[12pt,a4paper]{article}
\usepackage{geometry}
\usepackage[font=small,labelfont=bf,margin=\parindent,tableposition=top]{caption}
\usepackage{longtable}
 \geometry{
   a4paper,
   total={210mm,297mm},
   left=20mm,
   right=20mm,
   top=23mm,
   bottom=30mm,
 }

\begin{document}
\begin{longtable}{ll*{4}c}
  \caption{Title ...} \label{paneltable} \tabularnewline
  \caption*{Some description here} \tabularnewline
    \hline
    \multicolumn{6}{c}{Panel A:}                                                                                        \\ \hline
          &  & Dummy                     &                      & Dummy                     & Dummy                     \\ \cline{3-3} \cline{5-6} 
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\ \hline
    \multicolumn{6}{c}{Panel B}                                                                                         \\ \hline
          &  & \multicolumn{1}{l}{Dummy} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{Dummy} & \multicolumn{1}{l}{Dummy} \\ \cline{3-3} \cline{5-6} 
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\    \hline
    \newpage
    \caption*{Table \ref{paneltable} continued} \tabularnewline
    \multicolumn{6}{c}{Panel C}                                                                                         \\ \hline
          &  & Dummy                     &                      & Dummy                     & Dummy                     \\ \cline{3-3} \cline{5-6} 
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\
    Dummy &  & 1                         &                      & 1                         & 1                         \\ \hline

    \end{longtable}%
\end{document}

enter image description here

Related Question