10

I am writing a paper using the elsarticle document class. However, the article contains a long table which is sent to the next page, in the middle of the page although I have specified the position as 'here'. Is there any way to make the table split if one page is not long enough for the table?

Thank you very much for your very kind help.

4
  • The longtable package and its eponymous environment should help you get the job done.
    – Mico
    Mar 28 '16 at 14:21
  • I found it quite difficult to make sense of longtable for me as a latex beginner. I am looking for a way to do it without the longtable package. Thanks for your help. Mar 28 '16 at 14:43
  • You also have the ltablex package, which combines the functionalities of longtable and tabularx.
    – Bernard
    Mar 28 '16 at 14:44
  • 1
    the use of longtable is essentially identical to that of tabular, if you get an error you could ask a question about that, but table will never break and neither will tabular do you need to not use either of those environments. Mar 28 '16 at 15:49
6

To switch from a table/tabular combination to a longtable setup, the following adjustments are required:

  • delete \begin{tabular}{ccc} and change \begin{table} to \begin{longtable}{ccc};

  • delete \end{tabular} and change \end{table} to \end{longtable};

  • terminate the \caption directive with a double backslash;

  • omit the \centering directive that's usually provided for tabular material; and

  • organize the header and footer material with \endhead, \endfoot and, if needed, \endfirsthead and \endlastfoot, directives.

In the following screenshot, the tabular-like material and the positions of the captions look exactly the same for both tables; the first group was generated with a table/tabular combination, whereas the second was generated with a longtable environment.

enter image description here

\documentclass{article} 
\usepackage{longtable}
\usepackage{caption}
\begin{document}

\begin{table}
\centering
\caption{With \texttt{table} and \texttt{tabular} environments}\label{tab:a}
\begin{tabular}{ccc}
\hline
H1 & H2 & H3 \\
\hline
123 & 456 & 789 \\
\hline
\end{tabular}
\end{table}

\begin{longtable}{ccc}

% header and footer information
\caption{With \texttt{longtable} environment}\label{tab:b}\\
\hline
H1 & H2 & H3 \\
\hline
\endhead

\hline
\endfoot

% body of table
123 & 456 & 789 \\
\end{longtable}

\end{document}

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.