0

I have to insert a very long table in the tex file, for a two-column class, for example: \documentclass[5p]{elsarticle}.

The problem is that: the longtable package does not work in this class (as it is a twocolumn class). Also, the use of packages xtab or supertabular makes the table restricted to only one column.

Is there any way to insert the table in the mentioned two-column class, while the table comes as in a one-column document (the width of the table is much wider that can be placed in only one column of two). The problem is that: why the table is cut at the middle of the page. A typical code in \strip environment:

\documentclass[5p,times]{elsarticle}
\usepackage{cuted}
\usepackage{array}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{xtab}
\usepackage{booktabs}
\usepackage{lipsum}
\begin{document}    
\begin{frontmatter}
\title{Title}
\author{Name}

\begin{abstract}
The abstract.
\end{abstract}

\end{frontmatter}

\section{Introduction}

\lipsum[1-10]

\topcaption{This is the caption} \label{tab:xtab}
\tablefirsthead{\hline \multicolumn{1}{l}{\textbf{Command}} &
    \multicolumn{1}{l}{Effect} \\ \hline }
\tablehead{\multicolumn{2}{l}%
    {{\captionsize\bfseries \tablename\ \thetable{} --
            continued from previous page}} \\
    \hline \multicolumn{1}{l}{\textbf{Command}} &
    \multicolumn{1}{l}{\textbf{Effect}} \\ \hline }
\tablelasthead{\multicolumn{2}{c}%
    {{\captionsize\bfseries \tablename\ \thetable{} --
            concluded from previous page}} \\
    \hline \multicolumn{1}{l}{\textbf{Command}} &
    \multicolumn{1}{l}{\textbf{Effect}} \\ \hline }
\tabletail{\hline \multicolumn{2}{r}{{Continued on next page}} \\ \hline}
\tablelasttail{\hline}
\begin{strip}
\begin{center}
    \begin{xtabular}{p{0.4\textwidth}p{0.4\textwidth}}
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
        content & some text\\
    \end{xtabular}%
\end{center}
\end{strip}

\lipsum[1-10]

\end{document}
Alireza
  • 1
  • 1
  • 2
    You can use the \strip environment, from the cuted package. Note that, as it's not a floating environment, you'll have to use \captionof. – Bernard Feb 10 '19 at 16:15
  • Somewhat related: https://tex.stackexchange.com/questions/404472/how-can-i-add-a-table-style-caption-to-a-longtable-in-ieeetran and https://tex.stackexchange.com/questions/469547/wrap-text-beside-longtable/469725?r=SearchResults&s=3|0.0000#469725 and https://tex.stackexchange.com/questions/424744/how-to-remove-white-space-after-the-command-twocolumn/424822?r=SearchResults&s=10|0.0000#424822 – John Kormylo Feb 10 '19 at 18:15
  • can't you simply do \onecolumn\begin{longtable}.....\end{longtable}\twocolumn ? – David Carlisle Feb 10 '19 at 18:52
  • @ David I checked \onecolumn\begin{longtable}.....\end{longtable}\twocolumn, but the problem with it is that it makes a new page before and after the long table. – Alireza Feb 10 '19 at 18:56
  • @Bernard , I used the xtab package to insert the very long table in the strip environment. It works well except one problem: at the page, where the table begins, the table cannot go to the end of the page, I mean that if there is enough space, for example for the first ten rows, the table is cut after the fifth row, and the remained rows will insert to the next pages. – Alireza Feb 10 '19 at 18:57
  • @Alireza sure, but it's your document and you are hand writing it not generating thousands of tables from some database dump. just place the longtable at a suitable place in the source where a page break is required – David Carlisle Feb 10 '19 at 18:58
  • @Alireza: Can you say more about this problem? – Bernard Feb 10 '19 at 19:02
  • @Bernard, I used the package cuted and the environment \begin{strip} the table \end{strip}, where simultaneously used the xtab package to insert the table in xtabular environment. Suppose that the table contains 200 rows, and suppose the table begins at the middle of the page 5. The first 3 rows, appear in this page (while below these three rows, there exist empty enough space to cover more rows), and the row 4 and the next rows go to the next pages. – Alireza Feb 10 '19 at 19:12
  • Could you post a (complete) minimal example code reproducing the problem? Also, just in case: are you stuck to using xtabular? – Bernard Feb 10 '19 at 19:22
  • @Bernard , may you please run the code that is inserted in the main edited question? – Alireza Feb 10 '19 at 20:20
  • @Bernard , may you please run the code that is inserted in the main edited question? I am not stuck to using xtabular. I just looking for an appropriate way to insert a long table in two-column class well, without occurring any bad appearance. – Alireza Feb 10 '19 at 20:26
  • @Alireza: I've compiled your example, but unfortunately didn't find any work-around (including trying to fool longtable to make it believe we were in single-column mode – this resulted in the whole table disppearing). Maybe some guru will know what to do. – Bernard Feb 10 '19 at 21:51

0 Answers0