Longtable - 如何在表格环境中使用它?

Longtable - 如何在表格环境中使用它?

我有以下 latex 代码。我的问题是下面的表格不适合页面。我想在“面板 C”行上拆分表格,但我不知道如何在保留标题和说明的情况下做到这一点。

我尝试了这个longtable包,但没有成功。

\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

由于longtable是用于分页,因此浮动表格功能在这里并不真正有用。

longtable基本上像一样使用tabular,带有列描述,另外它还允许在环境\caption内部使用longtable

可以使用“普通”强制分页\newpage,也可以使用或阻止\nopagebreak分页\\*

\newpage我曾在桌子前用过Panel C

由于没有真正的表头,我省略了\endfirsthead等等。

\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}

在此处输入图片描述

相关内容