# How to prevent name from appearing unnecessarily on single authored elsarticle?

In a single authored article using elsarticle document class, the author's name appears unnecessarily after his email and url. How can I prevent this from happening?

\documentclass[final,times,letterpaper,authoryear,12pt]{elsarticle}

\begin{document}

\begin{frontmatter}

\title{Sample title
\tnoteref{t1}}
\tnotetext[t1]{Preliminary and incomplete.}

\author{John Doe\fnref{fn1}
}
\address{Bogus Department, Bogus University\par\vskip 18pt \textnormal{\normalsize{\today}}}
\fntext[fn1]{Contact: Bogus University, Bogus Department, 23 Grey Street, 3rd floor Fake City, USA.}
\begin{abstract}
Sample abstract
\end{abstract}

\end{frontmatter}

\end{document}

• Are you looking for a one-time hack, or do you want an "intelligent" handling or the one author vs multiple author situation? – jon Oct 14 '15 at 4:10

You shouldn't worry about the author addition as this is for submission to some journal.

However, a patch of the appropriate macros removes the "unnecessary name":

\documentclass[final,times,letterpaper,authoryear,12pt]{elsarticle}

\usepackage{etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\emailauthor}{(#2)}{}{}{}
\patchcmd{\urlauthor}{(#2)}{}{}{}

\begin{document}

\begin{frontmatter}

\title{Sample title
\tnoteref{t1}}
\tnotetext[t1]{Preliminary and incomplete.}

\author{John Doe\fnref{fn1}
}
\address{Bogus Department, Bogus University\par\vskip 18pt \textnormal{\normalsize{\today}}}
\fntext[fn1]{Contact: Bogus University, Bogus Department, 23 Grey Street, 3rd floor Fake City, USA.}
\begin{abstract}
Sample abstract
\end{abstract}

\end{frontmatter}

\end{document}

• While my answer is functionally equivalent, this should be the preferred approach. – Guho Oct 14 '15 at 4:26
• @Werner "You shouldn't worry about the author addition as this is for submission to some journal": technically yes. But I like the way thinks look there so I have adapted to use it with all my articles. – capadocia Oct 14 '15 at 19:45

You can redefine the \emailauthor and \urlauthor macros. Looking at elsarticle.cls, these macros are called from \ead:

\gdef\emailauthor#1#2{\stepcounter{ead}%
\let\corref\@gobble
}


and

\def\urlauthor#1#2{\g@addto@macro\@elsuads{\let\corref\@gobble%
}


Placing this in the preamble

\makeatletter
\let\corref\@gobble
}
}
\makeatother


yields:

versus:

For fun, here is a more "intelligent" solution that can automatically change the behavior based on the number of authors added.

\documentclass[final,times,letterpaper,authoryear,12pt]{elsarticle}
\usepackage{etoolbox}
\makeatletter
%1. Define counter
\newcounter{numberofauthors}
%2. Modify \emailauthor and \urlauthor
\pretocmd{\emailauthor}{\ifnum\value{numberofauthors}>1}{}{}
\pretocmd{\urlauthor}{\ifnum\value{numberofauthors}>1}{}{}
%3. Modify \author
%4. Modify frontmatter
\AtBeginEnvironment{frontmatter}{\makeatletter\immediate\write\@auxout{\string\setcounter{numberofauthors}{\expandafter\@arabic\thenumberofauthors}}\makeatother\setcounter{numberofauthors}{0}}
\AtEndEnvironment{frontmatter}{\makeatletter\immediate\write\@auxout{\string\setcounter{numberofauthors}{\expandafter\@arabic\thenumberofauthors}}\makeatother}
\makeatother
\begin{document}

\begin{frontmatter}
\title{Sample title
\tnoteref{t1}}
\tnotetext[t1]{Preliminary and incomplete.}
\author{John Doe\fnref{fn1}}
\fntext[fn1]{Contact: Bogus University, Bogus Department, 23 Grey Street, 3rd floor Fake City, USA.}

\author{Jane Doe}
\address{Another Bogus Department, Another Bogus University}
\fntext[fn1]{Contact: Another Bogus University, Another Bogus Department, 23 Grey Street, 3rd floor Fake City, USA.}

\begin{abstract}
Sample abstract
\end{abstract}

\end{frontmatter}

\end{document}


Which yields:

If the entries related to Jane Doe are removed, the following is produced:

Explanation:

The elsarticle class writes the \emailauthor and urlauthor commands to the aux file, which is then read in at the beginning of the document and these commands are executed, defining the @elseads and @elsuads macros to contain the email addresses and urls of the authors, respectively. With some surgery on elsarticle.cls, we can redefine \emailauthor and \urlauthor to exclude the name of the author if there is only one. These commands evaluate the number of authors courtesy of a new counter numberofauthors, the value of which is written before the \emailauthor and \urlauthor commands in the aux file.

Step 1: Add the numberofauthors counter.

elsarticle.cls defines an author counter, but its does not appear to be used as expected. Also, it is better to avoid conflicts by defining a new one.

\newcounter{numberofauthors}


Step 2: Make \emailauthor and \urlauthor dependent on numberofauthors.

This is accomplished by adding this to the preamble:

\pretocmd{\emailauthor}{\ifnum\value{numberofauthors}>1}{}{}
\pretocmd{\urlauthor}{\ifnum\value{numberofauthors}>1}{}{}


The \pretocmd{\emailauthor} and \apptocmd{\emailauthor} calls change the definition of \emailauthor from

\gdef\emailauthor#1#2{\stepcounter{ead}%
\let\corref\@gobble
}


\def\emailauthor#1#2{
\ifnum\value{numberofauthors}>1
\let\corref\@gobble
\else
\let\corref\@gobble
\fi}%


\pretocmd{\urlauthor} and \apptocmd{\urlauthor} similarly change the definition of \urlauthor.

Step 3: Increment numberofauthors whenever \author is called.

This is accomplished by:

\pretocmd{\author}{\addtocounter{numberofauthors}{1}}{}{}


Which redefines \author from

\def\author{\@ifnextchar[{\@@author}{\@author}}


to

\def\author{\addtocounter{numberofauthors}{1}\@ifnextchar[{\@@author}{\@author}}


Step4: Preserve the numberofauthors in the aux file.

This is accomplished by

\AtBeginEnvironment{frontmatter}{\makeatletter\immediate\write\@auxout{\string\setcounter{numberofauthors}{\expandafter\@arabic\thenumberofauthors}}\makeatother\setcounter{numberofauthors}{0}}
\AtEndEnvironment{frontmatter}{\makeatletter\immediate\write\@auxout{\string\setcounter{numberofauthors}{\expandafter\@arabic\thenumberofauthors}}\makeatother}


which is the same as:

\begin{frontmatter}
\makeatletter
\immediate\write\@auxout{\string\setcounter{numberofauthors}{\expandafter\@arabic\thenumberofauthors}}
\makeatother
\setcounter{numberofauthors}{0}

%Normal title and author definitions

\makeatletter
\immediate\write\@auxout{\string\setcounter{numberofauthors}{\expandafter\@arabic\thenumberofauthors}}
\makeatother
\end{frontmatter}


Behavior of the \setcounter pair is best explained by showing relevant portions of the aux file after each run:

First run (no previous aux file):

\setcounter{numberofauthors}{0}
\emailauthor{doe@gmail.com}{John Doe\fnref {fn1}}
\urlauthor{https://johndoe.com/}{John Doe\fnref {fn1}}
\setcounter{numberofauthors}{1}


On the second run, the numberofauthors counter is 0 when \emailauthor and \urlauthor are evaluated, yielding email addresses and urls without authors. Following the second run (using the above aux file) the aux file contains:

\setcounter{numberofauthors}{1}
\emailauthor{doe@gmail.com}{John Doe\fnref {fn1}}
\urlauthor{https://johndoe.com/}{John Doe\fnref {fn1}}
\setcounter{numberofauthors}{1}


This remains the same in subsequent runs, resulting in the desired behavior for \emailauthor and \urlauthor.