[Tex/LaTex] Table of Contents in Elsevier Class with two columns

elsarticletable of contentstwo-column

How can I show a table of contents in one column and below of abstract in Elsevier Class, considering twocolumn and preprint as selected options? My minimal example is below.

\documentclass[preprint,3p,twocolumn]{elsarticle}

\usepackage{lipsum}  
\makeindex  

\begin{document}

\title{Article of Test}  
\author{John Smith}  
\ead{email@email.com}

\journal{Science Now}

\begin{frontmatter}

\begin{abstract}  
\lipsum[1]  
\end{abstract}  

\begin{keyword}  
Key\sep Key\sep Key.  
\end{keyword}  

\end{frontmatter}

\tableofcontents

\section{Introduction}  
\lipsum[2-3]  

\subsection{First subsection}  
\lipsum[4-5]  

\subsection{Second subsection}  
\lipsum[6-7]  

\section{Second section}  
\lipsum[8-12]  

\end{document}  

Best Answer

You should patch the \maketitle macro to insert \tableofcontents at the appropriate location:

enter image description here

\documentclass[preprint,3p,twocolumn]{elsarticle}

\usepackage{lipsum,etoolbox}

\patchcmd{\maketitle}% <cmd>
  {\finalMaketitle}% <search>
  {\finalMaketitle\tableofcontents\vspace{\baselineskip}}% <replace>
  {}{}% <success><failure>

\begin{document}

\title{Article of Test}
\author{John Smith}
\ead{email@email.com}

\journal{Science Now}

\begin{frontmatter}

\begin{abstract}
\lipsum[1]
\end{abstract}

\begin{keyword}
Key\sep Key\sep Key.
\end{keyword}

\end{frontmatter}


\section{Introduction}
\lipsum[2-3]

\subsection{First subsection}
\lipsum[4-5]

\subsection{Second subsection}
\lipsum[6-7]

\section{Second section}
\lipsum[8-12]

\end{document}

A minor vertical correction is inserted after \tableofcontents to separate the ToC from the main body.


The above patch can be simplified by using only

\let\oldfinalMaketitle\finalMaketitle% Store \finalMaketitle
\renewcommand{\finalMaketitle}{% Update \finalMaketitle to...
  \oldfinalMaketitle% ...call original \finalMaketitle and...
  \tableofcontents\vspace{\baselineskip}}% ...add ToC.