如何使用表格环境在多个页面上创建表格

如何使用表格环境在多个页面上创建表格

编辑就像下面的一些评论一样,table环境不允许表格超过一页。然而,解决方案很好用

我需要制作一个跨多页的表格。标准方法似乎是使用环境ltablex。但是,它不起作用;我还假设table我使用的论文模板可能也需要环境(例如假设capture)。

\documentclass[11pt]{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{ltablex} 
\begin{document}

\begin{table}
\caption{Example of an table}
\label{tab:daypack}     
\begin{tabularx}{\linewidth}{@{}cX@{}}  
\toprule
\textbf{Column 1} & \textbf{Column 2} \\[6pt]
\midrule
\endhead
$R$ & 1This is an example sentence \\[6pt]
$R$ & 2As well as the line before \\[6pt]
$A$ & 3Also this is an example \\[6pt]
$R$ & 4This is an example sentence \\[6pt]
$R$ & 5As well as the line before \\[6pt]
$A$ & 6Also this is an example \\[6pt]
$R$ & 7This is an example sentence \\[6pt]
$R$ & 8As well as the line before \\[6pt]
$A$ & 9Also this is an example \\[6pt]
$R$ & 10This is an example sentence \\[6pt]
$R$ & 11As well as the line before \\[6pt]
$A$ & 12Also this is an example \\[6pt]
$R$ & 13This is an example sentence \\[6pt]
$R$ & 14As well as the line before \\[6pt]
$A$ & 15Also this is an example \\[6pt]
$R$ & 16This is an example sentence \\[6pt]
$R$ & 17As well as the line before \\[6pt]
$A$ & 18Also this is an example \\[6pt]
$R$ & 19This is an example sentence \\[6pt]
$R$ & 20As well as the line before \\[6pt]
$A$ & 21Also this is an example \\[6pt]
$R$ & 22This is an example sentence \\[6pt]
$R$ & 23As well as the line before \\[6pt]
$A$ & 24Also this is an example \\[6pt]
$R$ & 25This is an example sentence \\[6pt]
$R$ & 26As well as the line before \\[6pt]
$A$ & 27Also this is an example \\[6pt]
$R$ & 28This is an example sentence \\[6pt]
$R$ & 29As well as the line before \\[6pt]
$A$ & 30Also this is an example \\[6pt]
$R$ & 31This is an example sentence \\[6pt]
$R$ & 32As well as the line before \\[6pt]
$A$ & 33Also this is an example \\[6pt]
$R$ & 34This is an example sentence \\[6pt]
$R$ & 35As well as the line before \\[6pt]
$A$ & 36Also this is an example \\[6pt]
$R$ & 37This is an example sentence \\[6pt]
\bottomrule
\end{tabularx}   
\end{table}    

\end{document}

答案1

如果必须结合使用 tabularx 和 longtable,我更喜欢 ltxtable 而不是 ltablex:

\documentclass[11pt]{article}
\usepackage{booktabs}
\usepackage{ltxtable} 
\begin{document}



\LTXtable{\textwidth}{t1.tex}


\end{document}

哪里t1.tex

\begin{longtable}{@{}cX@{}}  
\toprule
\textbf{Column 1} & \textbf{Column 2} \\[6pt]
\midrule
\endhead
$R$ & 1This is an example sentence \\[6pt]
$R$ & 2As well as the line before \\[6pt]
$A$ & 3Also this is an example \\[6pt]
$R$ & 4This is an example sentence \\[6pt]
$R$ & 5As well as the line before \\[6pt]
$A$ & 6Also this is an example \\[6pt]
$R$ & 7This is an example sentence \\[6pt]
$R$ & 8As well as the line before \\[6pt]
$A$ & 9Also this is an example \\[6pt]
$R$ & 10This is an example sentence \\[6pt]
$R$ & 11As well as the line before \\[6pt]
$A$ & 12Also this is an example \\[6pt]
$R$ & 13This is an example sentence \\[6pt]
$R$ & 14As well as the line before \\[6pt]
$A$ & 15Also this is an example \\[6pt]
$R$ & 16This is an example sentence \\[6pt]
$R$ & 17As well as the line before \\[6pt]
$A$ & 18Also this is an example \\[6pt]
$R$ & 19This is an example sentence \\[6pt]
$R$ & 20As well as the line before \\[6pt]
$A$ & 21Also this is an example \\[6pt]
$R$ & 22This is an example sentence \\[6pt]
$R$ & 23As well as the line before \\[6pt]
$A$ & 24Also this is an example \\[6pt]
$R$ & 25This is an example sentence \\[6pt]
$R$ & 26As well as the line before \\[6pt]
$A$ & 27Also this is an example \\[6pt]
$R$ & 28This is an example sentence \\[6pt]
$R$ & 29As well as the line before \\[6pt]
$A$ & 30Also this is an example \\[6pt]
$R$ & 31This is an example sentence \\[6pt]
$R$ & 32As well as the line before \\[6pt]
$A$ & 33Also this is an example \\[6pt]
$R$ & 34This is an example sentence \\[6pt]
$R$ & 35As well as the line before \\[6pt]
$A$ & 36Also this is an example \\[6pt]
$R$ & 37This is an example sentence \\[6pt]
\bottomrule
\end{longtable}   

答案2

使用正确的代码,它可以正常工作。没有table环境——长表不可能是浮点数,并且紧随其后的是标题begin{tabularx}

    \documentclass[11pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{booktabs}
    \usepackage{ltablex}

    \begin{document}

    \label{tab:daypack}
    \begin{tabularx}{\linewidth}{@{}cX@{}}
    \caption{Example of an table}\\
    \toprule
    \textbf{Column 1} & \textbf{Column 2} \\[6pt]
    \midrule
    \endhead

    $R$ & 1This is an example sentence \\[6pt]
    $R$ & 2As well as the line before \\[6pt]
    $A$ & 3Also this is an example \\[6pt]
    $R$ & 4This is an example sentence \\[6pt]
    $R$ & 5As well as the line before \\[6pt]
    $A$ & 6Also this is an example \\[6pt]
    $R$ & 7This is an example sentence \\[6pt]
    $R$ & 8As well as the line before \\[6pt]
    $A$ & 9Also this is an example \\[6pt]
    $R$ & 10This is an example sentence \\[6pt]
    $R$ & 11As well as the line before \\[6pt]
    $A$ & 12Also this is an example \\[6pt]
    $R$ & 13This is an example sentence \\[6pt]
    $R$ & 14As well as the line before \\[6pt]
    $A$ & 15Also this is an example \\[6pt]
    $R$ & 16This is an example sentence \\[6pt]
    $R$ & 17As well as the line before \\[6pt]
    $A$ & 18Also this is an example \\[6pt]
    $R$ & 19This is an example sentence \\[6pt]
    $R$ & 20As well as the line before \\[6pt]
    $A$ & 21Also this is an example \\[6pt]
    $R$ & 22This is an example sentence \\[6pt]
    $R$ & 23As well as the line before \\[6pt]
    $A$ & 24Also this is an example \\[6pt]
    $R$ & 25This is an example sentence \\[6pt]
    $R$ & 26As well as the line before \\[6pt]
    $A$ & 27Also this is an example \\[6pt]
    $R$ & 28This is an example sentence \\[6pt]
    $R$ & 29As well as the line before \\[6pt]
    $A$ & 30Also this is an example \\[6pt]
    $R$ & 31This is an example sentence \\[6pt]
    $R$ & 32As well as the line before \\[6pt]
    $A$ & 33Also this is an example \\[6pt]
    $R$ & 34This is an example sentence \\[6pt]
    $R$ & 35As well as the line before \\[6pt]
    $A$ & 36Also this is an example \\[6pt]
    $R$ & 37This is an example sentence \\[6pt]
    \bottomrule
    \end{tabularx}

    \end{document} 

在此处输入图片描述

答案3

longtable软件包的使用longtable

\documentclass[11pt]{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{ltablex} 
\usepackage{longtable}
\begin{document}

\begin{longtable}{cc}  
\caption{Example of an table} \\
\textbf{Column 1} & \textbf{Column 2} \\[6pt]
$R$ & 1This is an example sentence \\[6pt]
$R$ & 2As well as the line before \\[6pt]
$A$ & 3Also this is an example \\[6pt]
$R$ & 4This is an example sentence \\[6pt]
$R$ & 5As well as the line before \\[6pt]
$A$ & 6Also this is an example \\[6pt]
$R$ & 7This is an example sentence \\[6pt]
$R$ & 8As well as the line before \\[6pt]
$A$ & 9Also this is an example \\[6pt]
$R$ & 10This is an example sentence \\[6pt]
$R$ & 11As well as the line before \\[6pt]
$A$ & 12Also this is an example \\[6pt]
$R$ & 13This is an example sentence \\[6pt]
$R$ & 14As well as the line before \\[6pt]
$A$ & 15Also this is an example \\[6pt]
$R$ & 16This is an example sentence \\[6pt]
$R$ & 17As well as the line before \\[6pt]
$A$ & 18Also this is an example \\[6pt]
$R$ & 19This is an example sentence \\[6pt]
$R$ & 20As well as the line before \\[6pt]
$A$ & 21Also this is an example \\[6pt]
$R$ & 22This is an example sentence \\[6pt]
$R$ & 23As well as the line before \\[6pt]
$A$ & 24Also this is an example \\[6pt]
$R$ & 25This is an example sentence \\[6pt]
$R$ & 26As well as the line before \\[6pt]
$A$ & 27Also this is an example \\[6pt]
$R$ & 28This is an example sentence \\[6pt]
$R$ & 29As well as the line before \\[6pt]
$A$ & 30Also this is an example \\[6pt]
$R$ & 31This is an example sentence \\[6pt]
$R$ & 32As well as the line before \\[6pt]
$A$ & 33Also this is an example \\[6pt]
$R$ & 34This is an example sentence \\[6pt]
$R$ & 35As well as the line before \\[6pt]
$A$ & 36Also this is an example \\[6pt]
$R$ & 37This is an example sentence \\[6pt]
\end{longtable}    

\end{document}

相关内容