From f21cb173e4a42219a48195c2a268320d358c5894 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 4 Jul 2018 21:25:46 +0000
Subject: elsarticle (4jul18)

git-svn-id: svn://tug.org/texlive/trunk@48134 c570f23f-e606-0410-a88d-b1316a301751
---
 .../source/latex/elsarticle/elsarticle.dtx         | 352 +++++++++++++++++----
 1 file changed, 287 insertions(+), 65 deletions(-)

(limited to 'Master/texmf-dist/source/latex/elsarticle/elsarticle.dtx')

diff --git a/Master/texmf-dist/source/latex/elsarticle/elsarticle.dtx b/Master/texmf-dist/source/latex/elsarticle/elsarticle.dtx
index 3ea78d9321b..8635c0047b9 100644
--- a/Master/texmf-dist/source/latex/elsarticle/elsarticle.dtx
+++ b/Master/texmf-dist/source/latex/elsarticle/elsarticle.dtx
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2007, 2008, 2009 by Elsevier Ltd
+% Copyright (C) 2007-2018 by Elsevier Ltd
 % -----------------------------------------------
 % 
 % This file may be distributed and/or modified under the
@@ -14,8 +14,9 @@
 % version 1999/12/01 or later.
 %
 % \fi
-% \CheckSum{2196}
+% \CheckSum{2627}
 %
+% $Id: elsarticle.dtx 125 2018-06-29 05:10:03Z rishi $
 % \iffalse
 %<*driver>
 \documentclass{ltxdoc}
@@ -73,20 +74,24 @@
 %    \begin{macrocode}
 %<*class>
 %% 
-%% $Id: elsarticle.cls,v 1.20 2008-10-13 04:24:12 cvr Exp $
+%% 
 %%
  \def\RCSfile{elsarticle}%
- \def\RCSversion{1.2.0}%
- \def\RCSdate{2009/09/17}%
+ \def\RCSversion{3.0}%
+ \def\RCSdate{2018/06/08}%
  \def\@shortjnl{\relax}
- \def\@journal{Elsevier Ltd} \def\@company{Elsevier Ltd}
+ \def\@journal{Elsevier Ltd} 
+ \def\@company{Elsevier Ltd}
  \def\@issn{000-0000}
  \def\@shortjid{elsarticle}
 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
 \ProvidesClass{\@shortjid}[\RCSdate, \RCSversion: \@journal]
 \def\ABD{\AtBeginDocument}
 \newif\ifpreprint \preprintfalse
+\newif\ifnonatbib \nonatbibfalse
 \newif\iflongmktitle \longmktitlefalse
+\newif\ifnopreprintline \nopreprintlinefalse
+\newif\ifdoubleblind \doubleblindfalse
 
 \def\@blstr{1}
 \newdimen\@bls
@@ -105,11 +110,13 @@
 \DeclareOption{preprint}{\global\preprinttrue
   \gdef\@blstr{1}\xdef\jtype{0}%
    \AtBeginDocument{\@twosidefalse\@mparswitchfalse}}
+\DeclareOption{nopreprintline}{\global\nopreprintlinetrue}
 \DeclareOption{final}{\gdef\@blstr{1}\global\preprintfalse}
 \DeclareOption{review}{\global\preprinttrue\gdef\@blstr{1.5}}
 \DeclareOption{authoryear}{\xdef\@biboptions{round,authoryear}}
 \DeclareOption{number}{\xdef\@biboptions{numbers}}
 \DeclareOption{numbers}{\xdef\@biboptions{numbers}}
+\DeclareOption{nonatbib}{\global\nonatbibtrue}
 \DeclareOption{longtitle}{\global\longmktitletrue}
 \DeclareOption{5p}{\xdef\jtype{5}\global\preprintfalse
   \ExecuteOptions{twocolumn}}
@@ -124,8 +131,24 @@
   \let\iiint\relax
   \let\iiiint\relax
   \let\idotsint\relax
-  \let\openbox\relax}}{\RequirePackage{times}}}
-\ExecuteOptions{a4paper,10pt,oneside,onecolumn,number,preprint}
+  \let\openbox\relax}}{\AtEndOfClass{\RequirePackage{times}}}}
+
+\DeclareOption{endfloat}{\IfFileExists{endfloat.sty}
+   {\AtEndOfClass{\RequirePackage[markers]{endfloat}}}{}}
+\DeclareOption{endfloats}{\IfFileExists{endfloat.sty}
+   {\AtEndOfClass{\RequirePackage[markers]{endfloat}}}{}}
+\DeclareOption{numafflabel}
+   {\AtBeginDocument{\def\theaffn{\arabic{affn}}}} %*%
+\DeclareOption{lefttitle}
+   {\AtBeginDocument{\def\elsarticletitlealign{flushleft}}} %*%
+\DeclareOption{centertitle}
+   {\AtBeginDocument{\def\elsarticletitlealign{center}}} %*%
+\DeclareOption{reversenotenum}
+   {\AtBeginDocument{\def\theaffn{\arabic{affn}}
+    \def\thefnote{\alph{fnote}}}}
+\DeclareOption{doubleblind}{\doubleblindtrue}
+
+\ExecuteOptions{a4paper,10pt,oneside,onecolumn,number,preprint,centertitle}
 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
 \ProcessOptions
 \LoadClass{article}
@@ -137,28 +160,38 @@
 %    \begin{macrocode}
 \let\comma\@empty
 \let\tnotesep\@empty
-\def\title#1{\gdef\@title{#1}}
 \let\@title\@empty
 
+\def\useelstitle{}
+
+\def\title#1{\g@addto@macro\@title{#1%
+       \global\let\tnoteref\@gobble}%
+       \g@addto@macro\useelstitle{#1}}
+
 \def\elsLabel#1{\@bsphack\protected@write\@auxout{}%
          {\string\Newlabel{#1}{\@currentlabel}}\@esphack}
 \def\Newlabel#1#2{\expandafter\xdef\csname X@#1\endcsname{#2}}
 
-\def\elsRef#1{\@ifundefined{X@#1}{0}{\csname X@#1\endcsname}%
-}
+\def\elsRef#1{\@ifundefined{X@#1}{0}{\csname X@#1\endcsname}}
 
-\def\tnotemark[#1]{\textsuperscript{\@for\@@tmark:=#1\do{%
-      \edef\tnotenum{\@ifundefined{X@\@@tmark}{1}{\elsRef{\@@tmark}}}%
-      \ifcase\tnotenum\or\ding{73}\or,\ding{73}\ding{73}\fi}}%
-}
 \let\@tnotemark\@empty
 
+\ifdoubleblind
+  \def\tnotemark[#1]{}
+\else
+  \def\tnotemark[#1]{\@for\mytmark:=#1\do{%
+       \expandafter\ifcase\csname X@\mytmark\endcsname\or$^{\star}$\or
+       $^{,\star\star}$\fi
+    }%
+}
+\fi
+
+\def\tnoteref#1{\tnotemark[{#1}]}
 \let\@tnotes\@empty
-\RequirePackage{pifont}
 \newcounter{tnote}
 \def\tnotetext[#1]#2{\g@addto@macro\@tnotes{%
-  \refstepcounter{tnote}\elsLabel{#1}%
-   \def\thefootnote{\ifcase\c@tnote\or\ding{73}\or\ding{73}\ding{73}\fi}%
+  \stepcounter{tnote}\elsLabel{#1}%
+    \def\thefootnote{\ifcase\c@tnote\or$\star$\or$\star\star$\fi}%
     \footnotetext{#2}}}
 
 \let\@nonumnotes\@empty
@@ -166,17 +199,20 @@
      \let\thefootnote\relax\footnotetext{#1}}}
 
 \newcounter{fnote}
+\def\thefnote{\arabic{fnote}}
 \def\fnmark[#1]{\let\comma\@empty
     \def\@fnmark{\@for\@@fnmark:=#1\do{%
     \edef\fnotenum{\@ifundefined{X@\@@fnmark}{1}{\elsRef{\@@fnmark}}}%
   \unskip\comma\fnotenum\let\comma,}}%
 }
 
+\def\fnref#1{\fnmark[#1]}
+
 \let\@fnotes\@empty\let\@fnmark\@empty
 \def\fntext[#1]#2{\g@addto@macro\@fnotes{%
-     \refstepcounter{fnote}\elsLabel{#1}%
-   \def\thefootnote{\thefnote}%
-   \global\setcounter{footnote}{\thefnote}%
+   \refstepcounter{fnote}\elsLabel{#1}%
+   \def\thefootnote{\c@fnote}%
+   \global\setcounter{footnote}{\c@fnote}%
    \footnotetext{#2}}}
 
 \def\cormark[#1]{\edef\cnotenum{\elsRef{#1}}%
@@ -193,19 +229,15 @@
     \footnotetext{#2}}}
 
 \let\@corref\@empty
-%\def\corref#1{\cormark[#1]}
 \def\corref#1{\edef\cnotenum{\elsRef{#1}}%
     \edef\@corref{\ifcase\cnotenum\or
          $\ast$\or$\ast\ast$\fi\hskip-1pt}}
 
-\def\fnref#1{\fnmark[#1]}
-\def\tnoteref#1{\tnotemark[#1]}
-
 \def\resetTitleCounters{\c@cnote=0
    \c@fnote=0 \c@tnote=0 \c@footnote=0}
 
 \let\eadsep\@empty
-\let\@elseads\@empty
+\def\@elseads{}
 \let\@elsuads\@empty
 \let\@cormark\@empty
 \def\hashchar{\expandafter\@gobble\string\~}
@@ -213,36 +245,43 @@
 \def\lbracechar{\expandafter\@gobble\string\{}
 \def\rbracechar{\expandafter\@gobble\string\}}
 
-\def\ead{\@ifnextchar[{\@uad}{\@ead}}
-\gdef\@ead#1{\bgroup\def\_{\string\underscorechar\space}%
-  \def\{{\string\lbracechar\space}%
-   \def~{\hashchar\space}%
-   \def\}{\string\rbracechar\space}%
-   \edef\tmp{\the\@eadauthor}
+\gdef\ead{\@ifnextchar[{\@uad}{\@ead}}
+\gdef\@ead#1{\bgroup
+   \def\_{\underscorechar}%
+   \def\{{\lbracechar}%
+   \def~{\hashchar}%
+   \def\}{\rbracechar}%
+   \edef\tmp{\the\@eadauthor}%
    \immediate\write\@auxout{\string\emailauthor
      {#1}{\expandafter\strip@prefix\meaning\tmp}}%
-  \egroup
+   \egroup
 }
 \newcounter{ead}
 \gdef\emailauthor#1#2{\stepcounter{ead}%
      \g@addto@macro\@elseads{\raggedright%
-      \let\corref\@gobble
-      \eadsep\texttt{#1} (#2)\def\eadsep{\unskip,\space}}%
+      \let\corref\@gobble\def\@@tmp{#1}%
+      \eadsep{\ttfamily\expandafter\strip@prefix\meaning\@@tmp}
+      (#2)\def\eadsep{\unskip,\space}}%
 }
 \gdef\@uad[#1]#2{\bgroup
-  \def~{\string\hashchar\space}%
-  \def\_{\string\underscorechar\space}%
+   \def~{\hashchar}%
+   \def\_{\underscorechar}%
+   \def~{\hashchar}%
+   \def\}{\rbracechar}%
    \edef\tmp{\the\@eadauthor}
    \immediate\write\@auxout{\string\urlauthor
      {#2}{\expandafter\strip@prefix\meaning\tmp}}%
   \egroup
 }
-\def\urlauthor#1#2{\g@addto@macro\@elsuads{\let\corref\@gobble%
-     \raggedright\eadsep\texttt{#1}\space(#2)%
+\gdef\urlauthor#1#2{\g@addto@macro\@elsuads{\let\corref\@gobble%
+     \def\@@tmp{#1}\raggedright\eadsep
+     {\ttfamily\expandafter\strip@prefix\meaning\@@tmp}\space(#2)%
      \def\eadsep{\unskip,\space}}%
 }
 
 \def\elsauthors{}
+\def\useauthors{}
+
 \def\pprinttitle{}
 \let\authorsep\@empty
 \let\sep\@empty
@@ -262,7 +301,8 @@
     \def\authorsep{\unskip,\space}%
     \global\let\sep\@empty\global\let\@corref\@empty
     \global\let\@fnmark\@empty}%
-    \@eadauthor={#2}
+    \@eadauthor={#2}%
+    \g@addto@macro\useauthors{#2; }%
 }
 
 \def\@author#1{\g@addto@macro\elsauthors{\normalsize%
@@ -273,8 +313,16 @@
       }%
     \def\authorsep{\unskip,\space}%
     \global\let\@fnmark\@empty
-    \global\let\sep\@empty}%
-    \@eadauthor={#1}
+    \global\let\@corref\@empty    \global\let\sep\@empty}%
+    \@eadauthor={#1}%
+    \g@addto@macro\useauthors{#1; }%
+}
+
+\AtBeginDocument{%
+  \@ifpackageloaded{hyperref}{%
+    \expandafter\gdef\csname Hy@title\endcsname{\useelstitle}%
+    \expandafter\gdef\csname Hy@author\endcsname{\useauthors}%
+   }{}
 }
 
 \def\elsaddress{}
@@ -324,13 +372,21 @@
     \def\authorsep{\par\vskip8pt}}}
 
 \newbox\absbox
+\let\@elsarticleabstitle\@empty %*%
+\def\abstracttitle#1{\gdef\@elsarticleabstitle{#1}} %*%
+\abstracttitle{Abstract} %*%
 \renewenvironment{abstract}{\global\setbox\absbox=\vbox\bgroup
   \hsize=\textwidth\def\baselinestretch{1}%
-  \noindent\unskip\textbf{Abstract}
+  \noindent\unskip\textbf{\@elsarticleabstitle} %*%
  \par\medskip\noindent\unskip\ignorespaces}
  {\egroup}
 
 \newbox\keybox
+\let\@elsarticlekwdtitle\@empty %*%
+\def\keywordtitle#1{\gdef\@elsarticlekwdtitle{#1}} %*%
+\def\keywordtitlesep#1{\gdef\@elsarticlekeywordtitlesep{#1}} %*%
+\keywordtitle{Keywords} %*%
+\keywordtitlesep{:\ }
 \def\keyword{%
   \def\sep{\unskip, }%
  \def\MSC{\@ifnextchar[{\@MSC}{\@MSC[2000]}}
@@ -340,7 +396,7 @@
   \global\setbox\keybox=\vbox\bgroup\hsize=\textwidth
   \normalsize\normalfont\def\baselinestretch{1}
   \parskip\z@
-  \noindent\textit{Keywords: }
+  \noindent\textit{\@elsarticlekwdtitle\@elsarticlekeywordtitlesep}
   \raggedright                         % Keywords are not justified.
   \ignorespaces}
 \def\endkeyword{\par \egroup}
@@ -350,7 +406,10 @@
 
 \def\printFirstPageNotes{%
   \iflongmktitle
-   \let\columnwidth=\textwidth\fi
+    \let\columnwidth=\textwidth
+  \fi
+\ifdoubleblind
+\else
   \ifx\@tnotes\@empty\else\@tnotes\fi
   \ifx\@nonumnotes\@empty\else\@nonumnotes\fi
   \ifx\@cornotes\@empty\else\@cornotes\fi
@@ -364,28 +423,49 @@
    \let\thefootnote\relax
    \footnotetext{\textit{URL:\space}%
      \@elsuads}\fi
+\fi
   \ifx\@fnotes\@empty\else\@fnotes\fi
   \iflongmktitle\if@twocolumn
    \let\columnwidth=\Columnwidth\fi\fi
 }
 
+%% Pushing text to begin on newpage %*%
+\def\newpage@after@title{title}
+\def\newpage@after@author{author}
+\def\newpage@after@abstract{abstract}
+\def\newpageafter#1%
+    {\gdef\@elsarticlenewpageafter{#1}}
+
 \long\def\pprintMaketitle{\clearpage
   \iflongmktitle\if@twocolumn\let\columnwidth=\textwidth\fi\fi
   \resetTitleCounters
   \def\baselinestretch{1}%
   \printFirstPageNotes
-  \begin{center}%
+  \begin{\elsarticletitlealign}%
  \thispagestyle{pprintTitle}%
    \def\baselinestretch{1}%
-    \Large\@title\par\vskip18pt
-    \normalsize\elsauthors\par\vskip10pt
-    \footnotesize\itshape\elsaddress\par\vskip36pt
+    \Large\@title\par\vskip18pt%
+    \ifx\@elsarticlenewpageafter\newpage@after@title% %*%
+      \newpage
+    \fi%
+    \ifdoubleblind
+      \vspace*{2pc}
+    \else
+      \normalsize\elsauthors\par\vskip10pt
+      \footnotesize\itshape\elsaddress\par\vskip36pt
+    \fi
+    \ifx\@elsarticlenewpageafter\newpage@after@author% %*%
+      \newpage
+    \fi%
     \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}}%
+    \ifx\@elsarticlenewpageafter\newpage@after@abstract% %*%
+      \newpage
+    \fi%
+    \end{\elsarticletitlealign}%
+    \gdef\thefootnote{\arabic{footnote}}%
   }
 
 \def\printWarning{%
@@ -408,17 +488,21 @@
 \long\def\MaketitleBox{%
   \resetTitleCounters
   \def\baselinestretch{1}%
-  \begin{center}%
+  \begin{\elsarticletitlealign}%
    \def\baselinestretch{1}%
     \Large\@title\par\vskip18pt
+  \ifdoubleblind
+    \vspace*{2pc}
+  \else
     \normalsize\elsauthors\par\vskip10pt
     \footnotesize\itshape\elsaddress\par\vskip36pt
+  \fi
     \hrule\vskip12pt
     \ifvoid\absbox\else\unvbox\absbox\par\vskip10pt\fi
     \ifvoid\keybox\else\unvbox\keybox\par\vskip10pt\fi
     \hrule\vskip12pt
-    \end{center}%
-  }
+    \end{\elsarticletitlealign}%
+}
 
 \def\FNtext#1{\par\bgroup\footnotesize#1\egroup}
 \newdimen\space@left
@@ -426,6 +510,39 @@
              \typeout{#1}%
              \typeout{******************************}%
 }
+
+\def\titlespancalculator#1#2#3#4{%
+  % break count
+  \@tempcnta=#4\relax%
+  % pagebreakcount increment
+  \advance\@tempcnta by 1\relax%
+  % title page height
+  \@tempdima=#1\relax%
+  % Page height - title page notes height (only for first break)
+  % Page height - textheight (for remaining breaks)
+  % Page height - title page notes height
+  \@tempdimb=#2\relax%
+  % Remaining title page height
+  \advance\@tempdima -\the\@tempdimb%
+  % Checks if remaining title page
+  % height less than textheight
+  \ifdim\the\@tempdima>#3\relax%
+     \titlespancalculator%
+      {\the\@tempdima}{#3}{#3}{\the\@tempcnta}%Break again
+  \else%
+  % Save break count and exit.
+     \xdef\savetitlepagespan{\the\@tempcnta}%
+  \fi%
+}%
+
+\long\def\myfor#1#2#3{%
+  \@tempcnta=#1\relax%
+  \ifnum#1<#2\relax%
+    \advance\@tempcnta by 1\relax%
+    #3%
+    \myfor{\the\@tempcnta}{#2}{#3}%
+  \fi}
+
 \long\def\getSpaceLeft{%\global\@twocolumnfalse%
    \global\setbox0=\vbox{\hsize=\textwidth\MaketitleBox}%
    \global\setbox1=\vbox{\hsize=\textwidth
@@ -436,6 +553,9 @@
     \@tempdima=\vsize
     \advance\@tempdima-\noteheight
     \advance\@tempdima-1\baselineskip
+    \xdef\savefpageheight{\the\@tempdima}%
+    \setbox2=\vbox{\titlespancalculator{\titleheight}%
+       {\savefpageheight}{\textheight}{0}}%
 }
 
   \skip\footins=24pt
@@ -449,10 +569,19 @@
    \ifnum\jtype=1
     \def\maketitle{%
       \iflongmktitle\getSpaceLeft
+        \ifdim\noteheight>0pt%
+    \advance\@tempdima-1.35\baselineskip
+        \fi%
        \global\setbox\els@boxa=\vsplit0 to \@tempdima
        \box\els@boxa\par\resetTitleCounters
        \thispagestyle{pprintTitle}%
        \printFirstPageNotes
+       \ifnum\savetitlepagespan>1\relax%
+       \myfor{2}{\savetitlepagespan}{%
+       \global\setbox\els@boxb=\vsplit0 to \textheight%\@tempdima
+       \box\els@boxb}
+       \else%
+       \fi%
        \box0%
       \else
        \finalMaketitle\printFirstPageNotes
@@ -462,10 +591,19 @@
  \ifnum\jtype=5
     \def\maketitle{%
       \iflongmktitle\getSpaceLeft
+        \ifdim\noteheight>0pt%
+    \advance\@tempdima-1.35\baselineskip
+        \fi%
        \global\setbox\els@boxa=\vsplit0 to \@tempdima
        \box\els@boxa\par\resetTitleCounters
        \thispagestyle{pprintTitle}%
        \printFirstPageNotes
+       \ifnum\savetitlepagespan>1\relax%
+       \myfor{2}{\savetitlepagespan}{%
+       \global\setbox\els@boxb=\vsplit0 to \textheight%\@tempdima
+       \twocolumn[\box\els@boxb]}
+       \else%
+       \fi%
        \twocolumn[\box0]%\printFirstPageNotes
       \else
        \twocolumn[\finalMaketitle]\printFirstPageNotes
@@ -474,11 +612,20 @@
   \else
   \if@twocolumn
     \def\maketitle{%
-      \iflongmktitle\getSpaceLeft
+        \iflongmktitle\getSpaceLeft
+          \ifdim\noteheight>0pt%
+    \advance\@tempdima-1.35\baselineskip
+        \fi%
        \global\setbox\els@boxa=\vsplit0 to \@tempdima
        \box\els@boxa\par\resetTitleCounters
        \thispagestyle{pprintTitle}%
        \printFirstPageNotes
+       \ifnum\savetitlepagespan>1\relax%
+       \myfor{2}{\savetitlepagespan}{%
+       \global\setbox\els@boxb=\vsplit0 to \textheight%\@tempdima
+       \twocolumn[\box\els@boxb]}
+       \else%
+       \fi%
        \twocolumn[\box0]%
       \else
        \twocolumn[\finalMaketitle]\printFirstPageNotes
@@ -487,10 +634,19 @@
    \else
     \def\maketitle{%
       \iflongmktitle\getSpaceLeft
+        \ifdim\noteheight>0pt%
+    \advance\@tempdima-1.35\baselineskip
+        \fi%
        \global\setbox\els@boxa=\vsplit0 to \@tempdima
        \box\els@boxa\par\resetTitleCounters
        \thispagestyle{pprintTitle}%
        \printFirstPageNotes
+       \ifnum\savetitlepagespan>1\relax%
+       \myfor{2}{\savetitlepagespan}{%
+       \global\setbox\els@boxb=\vsplit0 to \textheight%\@tempdima
+       \box\els@boxb}
+       \else%
+       \fi%
        \box0%
      \else
        \finalMaketitle\printFirstPageNotes
@@ -500,6 +656,20 @@
   \fi
  \fi
 \fi
+
+\let\@elsarticlemyfooter\@empty
+\let\@elsarticlemyfooteralign\@empty
+\def\@elsarticlemyfooteralignleft{L}
+\def\@elsarticlemyfooteralignright{R}
+\def\@elsarticlemyfooteraligncenter{C}
+
+\def\myfooter[#1]#2 %*%
+      {\gdef\@elsarticlemyfooteralign{#1}
+       \gdef\@elsarticlemyfooter{#2}}
+
+
+\def\myfooterfont#1{\gdef\@myfooterfont{#1}}
+\myfooterfont{\footnotesize\itshape}
 %    \end{macrocode}
 %    
 %\section{Headers/footers}
@@ -508,9 +678,27 @@
 \def\ps@pprintTitle{%
      \let\@oddhead\@empty
      \let\@evenhead\@empty
-     \def\@oddfoot{\footnotesize\itshape
-       Preprint submitted to \ifx\@journal\@empty Elsevier
-       \else\@journal\fi\hfill\today}%
+     \def\@oddfoot
+       {\hbox to \textwidth%
+        {\ifnopreprintline\relax\else
+        \@myfooterfont%
+         \ifx\@elsarticlemyfooteralign\@elsarticlemyfooteraligncenter%
+           \hfil\@elsarticlemyfooter\hfil%
+         \else%
+         \ifx\@elsarticlemyfooteralign\@elsarticlemyfooteralignleft%
+           \@elsarticlemyfooter\hfill{}%
+         \else%
+         \ifx\@elsarticlemyfooteralign\@elsarticlemyfooteralignright%
+           {}\hfill\@elsarticlemyfooter%
+         \else%
+               Preprint submitted to \ifx\@journal\@empty%
+                 Elsevier%
+            \else\@journal\fi\hfill\@date\fi%
+         \fi%
+         \fi%
+         \fi%
+         }
+       }%
      \let\@evenfoot\@oddfoot}
 %    \end{macrocode}
 %
@@ -716,8 +904,9 @@
 
 \@ifundefined{@biboptions}{\xdef\@biboptions{numbers}}{}
 \InputIfFileExists{\jobname.spl}{}{}
-\RequirePackage[\@biboptions]{natbib}
-
+\ifnonatbib\relax\else
+  \RequirePackage[\@biboptions]{natbib}
+\fi
 \newwrite\splwrite
 \immediate\openout\splwrite=\jobname.spl
 \def\biboptions#1{\def\next{#1}\immediate\write\splwrite{%
@@ -725,7 +914,6 @@
     ,\expandafter\strip@prefix\meaning\next}}}
 
 \let\baselinestretch=\@blstr
-
 %    \end{macrocode}
 %
 %\section{Page dimensions and margins for final form}
@@ -845,31 +1033,65 @@
 \@makeother\=
 }{}}
 %%
+\def\appendixname{Appendix }
 \renewcommand\appendix{\par
   \setcounter{section}{0}%
   \setcounter{subsection}{0}%
   \setcounter{equation}{0}
   \gdef\thefigure{\@Alph\c@section.\arabic{figure}}%
   \gdef\thetable{\@Alph\c@section.\arabic{table}}%
-  \gdef\thesection{\appendixname\@Alph\c@section}%
+  \gdef\thesection{\appendixname~\@Alph\c@section}%
   \@addtoreset{equation}{section}%
   \gdef\theequation{\@Alph\c@section.\arabic{equation}}%
+  \addtocontents{toc}{\string\let\string\numberline\string\tmptocnumberline}{}{}
+}
+
+%%%% \numberline width calculation for appendix.
+\newdimen\appnamewidth
+\def\tmptocnumberline#1{%
+   \setbox0=\hbox{\appendixname}
+   \appnamewidth=\wd0
+   \addtolength\appnamewidth{2.5pc}
+   \hb@xt@\appnamewidth{#1\hfill}
 }
-\def\appendixname{Appendix }
 
 %% Added for work with amsrefs.sty
 
 \@ifpackageloaded{amsrefs}%
   {}
-  {\let\bibsection\relax%
+  {%\let\bibsection\relax%
   \AtBeginDocument{\def\cites@b#1#2,#3{%
     \begingroup[%
         \toks@{\InnerCite{#2}#1}%
         \ifx\@empty#3\@xp\@gobble\fi
         \cites@c#3%
 }}}
-%
 %%
+%% Added for avoiding clash with cleveref.sty
+\@ifpackageloaded{cleveref}%
+ {}
+ {\def\tnotetext[#1]#2{\g@addto@macro\@tnotes{%
+    \refstepcounter{tnote}%
+    \immediate\write\@auxout{\string\Newlabel{#1}{\thetnote}}
+    \def\thefootnote{\ifcase\c@tnote\or$\star$\or$\star\star$\fi}%
+    \footnotetext{#2}}}
+%%%
+  \def\fntext[#1]#2{\g@addto@macro\@fnotes{%
+    \refstepcounter{fnote}%
+    \immediate\write\@auxout{\string\Newlabel{#1}{\thefnote}}
+    \def\thefootnote{\thefnote}%
+    \global\setcounter{footnote}{\c@fnote}%
+    \footnotetext{#2}}}
+%%%
+  \def\cortext[#1]#2{\g@addto@macro\@cornotes{%
+    \refstepcounter{cnote}%
+    \immediate\write\@auxout{\string\Newlabel{#1}{\thecnote}}
+    \def\thefootnote{\ifcase\c@cnote\or$\ast$\or
+    $\ast\ast$\fi}%
+    \footnotetext{#2}}}
+}
+
+\def\textmarker#1#2{\textcolor{#1}{#2}}%*%
 %</class>
 %
 %    \end{macrocode}
-- 
cgit v1.2.3

