1

To make a long story short, we have:

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

And the table.tex file has a \begin{longtable} format in it.

I will include a sample code WITHOUT the \input{} statement.

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

Ok, this seems hard for me to communicate, but we use this format even if the tables are shorter. This keeps the list of tables and captions formatted correctly. Now, when we have more information and the table is larger (uncomment the last lines of data), longtable does not work and if we remove \begin{table} the caption does not match and show up in the list of tables correctly.

Is there a long table procedure that keeps the list of tables and captions?

  • 2
    Just remove the table environment an put \caption in the longtable. longtable allows \caption and works with lists of tables. – David Carlisle Dec 8 '15 at 22:55
3

enter image description here

longtable supports captions directly.

\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}
  • I would like to put the '\caption' at the bottom of the table, but it leaves too little space between the table and caption. – adm Dec 21 '15 at 20:44
  • @adm you can use \\[5cm]\caption{zzzz} (but captions at the end of a multi-page table don't really work, it means the reader sees pages of data before finding out what it's about) – David Carlisle Dec 21 '15 at 23:53
  • I will consider placing the captions at the top, but if using \\[5cm]\caption{zzzz} the first \hline column is extended also. – adm Dec 22 '15 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.