Problem with elsarticle and lineno

I am answering my own question.

I managed to solve this issue by just moving the \linenumbers sentence to the beginning of the main text —that is:

\documentclass[preprint,review]{elsarticle}

\usepackage{lipsum}

% ADDING LINENUMBERS FOR REVIEWING:
\usepackage{lineno}
%    \linenumbers   <---- NOT HERE !!!

\journal{The Name Of The Journal}

\begin{document}

\begin{frontmatter}

\title{\begin{linenumbers}The Tile Of The Article\end{linenumbers}}


\author[]{Name1 Surname1\corref{cor1}}
\ead{[email protected]}
\cortext[cor1]{Corresponding author. Tel.: WHATEVER; Fax: WHATEVER.}
\author[]{Name2 Surname2}
\ead{[email protected]}
\author[]{Name2 Surname3}
\ead{[email protected]}
\address{Research Structure Name, University Name, Full Postal Address.}



\begin{abstract}

\lipsum[31]

\end{abstract}

\begin{keyword}
Keyword1; Keyword2; Keyword3; Keyword4; Keyword5
\end{keyword}

\end{frontmatter}

\linenumbers  %% <---- BUT HERE !

\section{Introduction and background}

\subsection{Introduction}

\lipsum[1-5]

\subsection{Background}

\lipsum[6-15]

\subsection{Aims and scope}

\lipsum[16-20]

\section{Conclusions}

\lipsum[21-30]

\section*{Acknowledgements}

Thanks to all!

\end{document}

This is the result:

MWE result

It is a little bit strange that the title line gets actually numbered, but it is OK for me that the abstract is not numbered, after reading the answer by @Loop-Space to a similar question regarding lineno: https://tex.stackexchange.com/a/11406/8283, where he points out that lineno is intended to number only the main text.

It's not perfect, but it is OK for me.


An analysis of the problem would be quite time consuming, because lineno does many hacks and elsarticle too.

A simple workaround is to add \enlargethispage{-2\baselineskip} after \end{frontmatter}. In order to have this in the same place with \usepackage{lineno} so that you can easily remove it when the final version is submitted is

% ADDING LINENUMBERS FOR REVIEWING:
\usepackage{lineno}
\linenumbers
\makeatletter
\g@addto@macro\endfrontmatter{\enlargethispage{-2\baselineskip}}
\makeatother

enter image description here


Moving the \linenumbers command to the beginning of the main text is now an official advice from the company that provides technical support for this style file: FAQ - elsarticle.cls (see p.13 of the "Preamble and Front matter section")