4

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}
1
  • 2
    You don't need the table environment. Just use \caption` and \label inside of \begin{longtable}{llll} etc. By the way: The document misses \begin{document} and \end{document}, not \end document
    – user31729
    Sep 9, 2015 at 14:36

1 Answer 1

2

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

6
  • Thank you for your answer. The issue is that I want to keep using the \caption*{Some description here }, to write a caption for my table in line with what I have done with my other tables on the document.
    – phdstudent
    Sep 9, 2015 at 14:54
  • @volcompt: Yes, where's the problem?
    – user31729
    Sep 9, 2015 at 14:58
  • On your code above, you included: "% \caption*{Some description here } ", as a comment. If tou remove the "%" symbol the code no longer compiles correctly.
    – phdstudent
    Sep 9, 2015 at 15:06
  • @volcompt: Uncommented: It wasn't clear from your post that \caption* is important
    – user31729
    Sep 9, 2015 at 15:07
  • 1
    @volcompt: Yes, see my update please
    – user31729
    Sep 9, 2015 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .