[Tex/LaTex] How to get rid of the two lines for empty abstract and keyword sections

front-matter

How can I get rid of the two lines resulting from empty abstraction and keyword sections? Thanks.

enter image description here

The code is

\documentclass[preprint,12pt]{elsarticle}

\usepackage[nodots]{numcompress}

\biboptions{sort&compress}

\journal{A Journal}

\begin{document}

\begin{frontmatter}

  \title{My Title}

  \author[myaddr]{Author 1}
  \author[myaddr]{Author 2}
  \address[myaddr]{An Address}

  %% \begin{abstract}                                                                                                                                          
  %%   Here's an abstract.                                                                                                                                     
  %% \end{abstract}                                                                                                                                            

  %% \begin{keyword}                                                                                                                                           
  %%   keyword1 \sep keyword2 \sep keyword3                                                                                                                    
  %% \end{keyword}                                                                                                                                             

\end{frontmatter}
\section{Introduction}
\label{intro}


\end{document}

Best Answer

I had to comment the numcompress package out.

The relevant lines are contained in \pprintMaketitle, being two \hrule statements. For a quick solution, I commented those \hrule statements out:

\documentclass[preprint,12pt]{elsarticle}

\makeatletter
\long\def\pprintMaketitle{\clearpage
  \iflongmktitle\if@twocolumn\let\columnwidth=\textwidth\fi\fi
  \resetTitleCounters
  \def\baselinestretch{1}%
  \printFirstPageNotes
  \begin{center}%
 \thispagestyle{pprintTitle}%
 \def\baselinestretch{1}%
    \Large\@title\par\vskip18pt
    \normalsize\elsauthors\par\vskip10pt
    \footnotesize\itshape\elsaddress\par\vskip36pt
%    \hrule\vskip12pt
    \ifvoid\absbox\else\unvbox\absbox\par\vskip10pt\fi
    \ifvoid\keybox\else\unvbox\keybox\par\vskip10pt\fi
%    \hrule\vskip12pt
    \end{center}%
  \gdef\thefootnote{\arabic{footnote}}%
  }
\makeatother

%\usepackage[nodots]{numcompress}

\biboptions{sort&compress}

\journal{A Journal}

\begin{document}

\begin{frontmatter}

  \title{My Title}

  \author[myaddr]{Author 1}
  \author[myaddr]{Author 2}
  \address[myaddr]{An Address}

  %% \begin{abstract}                                                                                                                                          
  %%   Here's an abstract.                                                                                                                                     
  %% \end{abstract}                                                                                                                                            

  %% \begin{keyword}                                                                                                                                           
  %%   keyword1 \sep keyword2 \sep keyword3                                                                                                                    
  %% \end{keyword}                                                                                                                                             

\end{frontmatter}
\section{Introduction}
\label{intro}


\end{document}

Edit A somehow shorter version, with xpatch package:

\documentclass[preprint,12pt]{elsarticle}

\usepackage{xpatch}

% Patching the \hrule\vskip12pt out .. do it twice!!!
\makeatletter
\xpatchcmd{\pprintMaketitle}{%
  \hrule\vskip12pt%
}{}{\typeout{Success}}{}

% Injection the date as a replacement of the 2nd `\hrule` stuff
\xpatchcmd{\pprintMaketitle}{%
  \hrule\vskip12pt%
}{\@date}{\typeout{Success}}{}
\makeatother

%\usepackage[nodots]{numcompress}

\biboptions{sort&compress}

\journal{A Journal}

\begin{document}

\begin{frontmatter}
\title{Theory on Brontosaurs}

\author[myaddr]{Anne Elk (Misses)}
\author[myaddr]{Arthur Gumby (Brain specialist)}
\address[myaddr]{Ministry of Silly Walks}

  %% \begin{abstract}                                                                                                                                          
  %%   Here's an abstract.                                                                                                                                     
  %% \end{abstract}                                                                                                                                            

  %% \begin{keyword}                                                                                                                                           
  %%   keyword1 \sep keyword2 \sep keyword3                                                                                                                    
  %% \end{keyword}                                                                                                                                             

\end{frontmatter}
\section{Introduction}
\label{intro}


\end{document}

enter image description here