0

I'm trying to create a pretty long table in an elsarticle.cls with a two column layout. However, I haven't been able to find a suitable option to break my table so it can fit on a single page and using the two column setting. I provide this example:

\documentclass[5p]{elsarticle}

\usepackage{array}
\usepackage{booktabs}
\usepackage{float}
\usepackage{ragged2e}

\newcommand{\Title}[1]{\justifying\caption{#1}}
\newcommand{\Source}[1]{\caption*{\justifying\textbf{Source:} #1}}
\newcommand{\Note}[1]{\caption*{\justifying\textbf{Note:} #1}}

\begin{document}

%----------------------------------
\begin{frontmatter}

   \title{Two column tables in elsarticle document class}

   \author{A. J. Lee}

   \begin{abstract}
      This document asks how to break tables in two column documents.
   \end{abstract}

\end{frontmatter}

%----------------------------------
\section{Introduction}
   See table  
\begin{table}[H]
   \centering
   \begin{tabular}{p{1cm} p{1cm} p{5cm}}
   % Header
   \toprule
   \textbf{Item} & 
   \textbf{Code} & 
   % Content
   \textbf{Description} \\
   \midrule
   % Content
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   \bottomrule
   \end{tabular}
   \Title{Table}
   \Source{Own creation}
   \Note{This is an example}
\end{table}

Since this is a two column layout I can't use the longtable package. Also, I haven't used the supertabular package since I have created some new commands: \Title, \Source and \Note, and there is no place (I guess) for them within the supertabular options and maitaining the same appearance.

This is my pdf outcome:

enter image description here

  • Are you sure about your self-defined commands \Source and \Note?. To me, using the caption command for them does not seem to be a good idea, as this will most likely lead to strange numbering of the tables. – leandriis Jun 6 '18 at 9:04
  • It is possible to put a longtable into two columns (see tex.stackexchange.com/questions/316767/…) but only if it takes up the entire column. – John Kormylo Jun 6 '18 at 13:14
  • @leandriis yes, they work properly. Since I use \caption* instead of \caption there's no numbering conflict. – Alder Miguel Jun 7 '18 at 3:57
  • @JohnKormylo I don't think using images would be a good idea since they may suffer some downgrades. – Alder Miguel Jun 7 '18 at 4:01
  • PDFs are not pixelated, and suffer no loss of resolution when copied. Even inserted pixelated images are stored in their original resolution. – John Kormylo Jun 7 '18 at 12:52
1

You could achieve a similar result using the supertabular package:

\documentclass[5p]{elsarticle}

\usepackage{array}
\usepackage{booktabs}
\usepackage{float}
\usepackage{ragged2e}

\usepackage{supertabular}

\begin{document}

\begin{frontmatter}

   \title{Two column tables in elsarticle document class}

   \author{A. J. Lee}

   \begin{abstract}
      This document asks how to break tables in two column documents.
   \end{abstract}

\end{frontmatter}

\section{Introduction}
   See table

\begin{center}
\tablehead{%
   \toprule
   \textbf{Item} & 
   \textbf{Code} & 
   \textbf{Description} \\
   \midrule}
\bottomcaption{Table caption}
\begin{supertabular}{p{1cm} p{1cm} p{5cm}}
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   \bottomrule
\end{supertabular}
\justifying
\textbf{Source:} Here is the source of the table

\textbf{Notes:} Here are some table notes
\end{center}
\end{document}

enter image description here

  • @leandriss Thank you for your help. I solved the problem. I think I was missing something when using the supertabular package. Any way, I used a little hack to solve the captions problem. I will provide the code bellow. – Alder Miguel Jun 7 '18 at 17:11
0

This solution to my problem is based on @leandriss' own solution. I just (1) added some options to my captions so they look better, (2) used more of the supertabular package options, and (3) used an empty table environment with the [H] option from the float package at the end of the table and some \vspace adjustment. I share the code:

\documentclass[authoryear,5p]{elsarticle}

\usepackage{array}
\usepackage{booktabs}
\usepackage{float}
\usepackage{ragged2e}
\usepackage{supertabular}
\usepackage[skip = 2pt,
           font = footnotesize,
           label font = bf,
           justification = justified]{caption} % Etiquetas
\captionsetup{justification = justified,
             singlelinecheck = false} % Alinear etiquetas a la izquierda.

\newcommand{\Title}[1]{\caption{#1}}
\newcommand{\Source}[1]{\caption*{\justifying\textbf{Fuente:} #1}}
\newcommand{\Note}[1]{\caption*{\justifying\textbf{Nota:} #1}}

\begin{document}

%----------------------------------
\begin{frontmatter}

   \title{Two column tables in elsarticle document class}

   \author{A. J. Lee}

   \begin{abstract}
      This document asks how to break table in two column documents.
   \end{abstract}

\end{frontmatter}

%----------------------------------
\section{Introduction}
   See table:  \ref{tab:1}.
\begin{center}
   % Main Header
   \tablefirsthead{%
      \toprule
      \textbf{Item} & 
      \textbf{Code} & 
      \textbf{Description} \\
   \midrule
   }
   % Tail
   \tabletail{%
      \midrule
      \multicolumn{3}{l}{\emph{cotinue}} \\
      \midrule
   }
   % Head
   \tablehead{%
      \midrule
      \multicolumn{3}{l}{\emph{cotinue}} \\
      \midrule
   }
   % Last Tail
   \tablelasttail{%
      \bottomrule
   }
   \begin{supertabular}{p{1cm} p{1cm} p{5cm}}
   % Content
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   A & 777 & Some random stuff \\
   \end{supertabular}
\end{center} \vspace{-16pt}
\begin{table}[H]
   \Title{Table}
   \label{tab:1}
   \Source{Own creation}
   \Note{This is an example}
\end{table}

\end{document}

This is the final outcome:

enter image description here

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.