TransWikia.com

How to make table split in two pages

TeX - LaTeX Asked by Faisal Mustafa on December 25, 2020

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.

One Answer

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}

Correct answer by Mico on December 25, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP