在 \begin{table} 中使用 \begin{longtable} 来保持标题和表格列表正常工作

在 \begin{table} 中使用 \begin{longtable} 来保持标题和表格列表正常工作

长话短说,我们有:

\begin{table}
 \input{table.tex}
 \caption{The table too long for one page}
\end{table}

并且该table.tex文件具有\begin{longtable}其格式。

我将提供一个不带语句的示例代码\input{}

\documentclass[notitlepage]{article}
\usepackage{longtable}
\begin{document}
\listoftables
\begin{table} 
%% This is the beginning of the \input{table.tex}
\begin{longtable}{ l | l | l | l }
ID & Code & \#  & Total \\
\hline
\endfirsthead
ID & Code & \#  & Total \\
\hline
\endhead
1&17&44&29 \\
2&43&27&39 \\
3&16&40&18 \\
4&39&36&45 \\
5&15&13&45 \\
6&24&17&13 \\
7&28&34&7 \\
8&28&38&4 \\
9&13&43&14 \\
10&39&37&41 \\
11&4&38&37 \\
12&32&36&22 \\
13&38&20&30 \\
14&17&20&41 \\
15&29&43&23 \\
16&16&43&18 \\
17&7&43&32 \\
18&4&4&44 \\
19&42&7&11 \\
20&44&18&36 \\
21&34&16&20 \\
22&27&20&17 \\
23&20&31&43 \\
24&5&43&28 \\
25&40&18&17 \\
26&11&40&26 \\
27&12&43&9 \\
%28&6&35&5 \\
%29&14&29&8 \\
%30&26&42&6 \\
%31&33&4&41 \\
%32&45&20&25 \\
%33&45&35&15 \\
%34&33&39&36 \\
%35&15&38&14 \\
%36&40&29&23 \\
%37&16&5&23 \\
%38&29&11&36 \\
%39&13&38&10 \\
%40&39&10&38 \\
%41&22&43&12 \\
%42&8&35&22 \\
%43&26&40&14 \\
%44&41&32&42 \\
%45&20&25&18 \\
%46&12&23&28 \\
%47&15&10&21 \\
%48&39&29&35 \\
%49&16&9&45 \\
%50&29&10&8 \\
%51&25&8&42 \\
%52&27&43&5 \\
%53&34&24&41 \\
\end{longtable}
%% This is the end of the \input{table.tex}
\center     
\caption{The table too long for one page}   
\end{table}
\end{document}

好吧,这对我来说似乎很难沟通,但即使表格较短,我们也会使用这种格式。这样可以保持表格和标题列表的格式正确。现在,当我们有更多信息并且表格较大时(取消注释最后几行数据),longtable 不起作用,如果我们删除\begin{table}标题,则标题不匹配并正确显示在表格列表中。

是否有一个长表程序可以保存表格和标题的列表?

答案1

在此处输入图片描述

longtable直接支持字幕。

\documentclass[notitlepage]{article}
\usepackage{longtable}
\begin{document}
\listoftables

%% This is the beginning of the \input{table.tex}
\begin{longtable}{ l | l | l | l }
\caption{The table too long for one page}\\
ID & Code & \#  & Total \\
\hline
\endfirsthead
ID & Code & \#  & Total \\
\hline
\endhead
1&17&44&29 \\
2&43&27&39 \\
3&16&40&18 \\
4&39&36&45 \\
5&15&13&45 \\
6&24&17&13 \\
7&28&34&7 \\
8&28&38&4 \\
9&13&43&14 \\
10&39&37&41 \\
11&4&38&37 \\
12&32&36&22 \\
13&38&20&30 \\
14&17&20&41 \\
15&29&43&23 \\
16&16&43&18 \\
17&7&43&32 \\
18&4&4&44 \\
19&42&7&11 \\
20&44&18&36 \\
21&34&16&20 \\
22&27&20&17 \\
23&20&31&43 \\
24&5&43&28 \\
25&40&18&17 \\
26&11&40&26 \\
27&12&43&9 \\
%28&6&35&5 \\
%29&14&29&8 \\
%30&26&42&6 \\
%31&33&4&41 \\
%32&45&20&25 \\
%33&45&35&15 \\
%34&33&39&36 \\
%35&15&38&14 \\
%36&40&29&23 \\
%37&16&5&23 \\
%38&29&11&36 \\
%39&13&38&10 \\
%40&39&10&38 \\
%41&22&43&12 \\
%42&8&35&22 \\
%43&26&40&14 \\
%44&41&32&42 \\
%45&20&25&18 \\
%46&12&23&28 \\
%47&15&10&21 \\
%48&39&29&35 \\
%49&16&9&45 \\
%50&29&10&8 \\
%51&25&8&42 \\
%52&27&43&5 \\
%53&34&24&41 \\
\end{longtable}
%% This is the end of the \input{table.tex}





\end{document}

相关内容