如何防止名称不必要地出现在单一作者的 elsarticle 上?

如何防止名称不必要地出现在单一作者的 elsarticle 上?

在使用 elsarticle 文档类的单一作者文章中,作者的姓名不必要地出现在其电子邮件和 URL 之后。我该如何防止这种情况发生?

\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.}
\ead{[email protected]}
\ead[url]{https://johndoe.com/}
\begin{abstract}
Sample abstract
\end{abstract}

\end{frontmatter}

\end{document}

答案1

您不必担心作者的添加,因为这是提交给某些期刊的。

但是,适当宏的补丁可以删除“不必要的名称”:

在此处输入图片描述

\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.}
\ead{[email protected]}
\ead[url]{https://johndoe.com/}
\begin{abstract}
Sample abstract
\end{abstract}

\end{frontmatter}

\end{document}

答案2

您可以重新定义\emailauthor\urlauthor宏。查看elsarticle.cls,这些宏是从调用的\ead

\gdef\emailauthor#1#2{\stepcounter{ead}%
    \g@addto@macro\@elseads{\raggedright%
    \let\corref\@gobble
    \eadsep\texttt{#1} (#2)\def\eadsep{\unskip,\space}}%
}

\def\urlauthor#1#2{\g@addto@macro\@elsuads{\let\corref\@gobble%
    \raggedright\eadsep\texttt{#1}\space(#2)%
    \def\eadsep{\unskip,\space}}%
}

将其放在序言中

\makeatletter
\gdef\emailauthor#1#2{\stepcounter{ead}%
     \g@addto@macro\@elseads{\raggedright%
      \let\corref\@gobble
      \eadsep\texttt{#1}\def\eadsep{\unskip,\space}}%
}
\def\urlauthor#1#2{\g@addto@macro\@elsuads{\let\corref\@gobble%
    \raggedright\eadsep\texttt{#1}%
    \def\eadsep{\unskip,\space}}%
}
\makeatother

产量:

在此处输入图片描述

相对:

在此处输入图片描述

答案3

为了好玩,这里有一个更“智能”的解决方案,可以根据添加的作者数量自动改变行为。

\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}{}{}
        \apptocmd{\emailauthor}{\else\stepcounter{ead}\g@addto@macro\@elseads{\raggedright\let\corref\@gobble\eadsep\texttt{#1}\def\eadsep{\unskip,\space}}\fi}{}{}
        \pretocmd{\urlauthor}{\ifnum\value{numberofauthors}>1}{}{}
        \apptocmd{\urlauthor}{\else\g@addto@macro\@elsuads{\let\corref\@gobble\raggedright\eadsep\texttt{#1}\def\eadsep{\unskip,\space}}\fi}{}{}
        %3. Modify \author
        \pretocmd{\author}{\addtocounter{numberofauthors}{1}}{}{}
        %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}}
\address{Bogus Department, Bogus University}
\fntext[fn1]{Contact: Bogus University, Bogus Department, 23 Grey Street, 3rd floor Fake City, USA.}
\ead{[email protected]}
\ead[url]{https://johndoe.com/}

\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.}
\ead{[email protected]}
\ead[url]{https://janedoe.com/}

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

\end{frontmatter}

\end{document}

得出的结果是:

多位作者

如果删除与 Jane Doe 相关的条目,则会产生以下内容:

单一作者

解释:

该类elsarticle\emailauthorurlauthor命令写入aux文件,然后在文档开头读取并执行这些命令,定义@elseads@elsuads宏以分别包含作者的电子邮件地址和网址。通过对进行一些修改elsarticle.cls,我们可以重新定义\emailauthor\urlauthor以排除作者姓名(如果只有一个)。这些命令通过新的计数器来评估作者的数量numberofauthors,其值写入文件中的和\emailauthor命令。\urlauthoraux

步骤1:添加numberofauthors计数器。

elsarticle.cls定义了一个author计数器,但似乎没有按预期使用。此外,最好通过定义一个新的计数器来避免冲突。

\newcounter{numberofauthors}

第2步:使\emailauthor并且\urlauthor依赖于numberofauthors

这是通过在序言中添加以下内容来实现的:

\pretocmd{\emailauthor}{\ifnum\value{numberofauthors}>1}{}{}
\apptocmd{\emailauthor}{\else\stepcounter{ead}\g@addto@macro\@elseads{\raggedright\let\corref\@gobble\eadsep\texttt{#1}\def\eadsep{\unskip,\space}}\fi}{}{}
\pretocmd{\urlauthor}{\ifnum\value{numberofauthors}>1}{}{}
\apptocmd{\urlauthor}{\else\g@addto@macro\@elsuads{\let\corref\@gobble\raggedright\eadsep\texttt{#1}\def\eadsep{\unskip,\space}}\fi}{}{}

\pretocmd{\emailauthor}调用改变来自\apptocmd{\emailauthor}的定义\emailauthor

\gdef\emailauthor#1#2{\stepcounter{ead}%
     \g@addto@macro\@elseads{\raggedright%
      \let\corref\@gobble
      \eadsep\texttt{#1} (#2)\def\eadsep{\unskip,\space}}%
}

至(*此处已格式化以便于阅读):

\def\emailauthor#1#2{
    \ifnum\value{numberofauthors}>1
        \stepcounter{ead}%
        \g@addto@macro\@elseads{\raggedright%
        \let\corref\@gobble
        \eadsep\texttt{#1} (#2)\def\eadsep{\unskip,\space}}%
    \else
        \stepcounter{ead}%
        \g@addto@macro\@elseads{\raggedright%
        \let\corref\@gobble
        \eadsep\texttt{#1}\def\eadsep{\unskip,\space}}%
    \fi}%

\pretocmd{\urlauthor}\apptocmd{\urlauthor}同样改变 的定义\urlauthor

步骤3:numberofauthors每当\author被调用时就增加。

这是通过以下方式实现的:

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

重新\author定义

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

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

步骤4:将其保存numberofauthorsaux文件中。

这是通过

\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}

这与以下内容相同:

\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}

通过在每次运行后\setcounter显示文件的相关部分可以最好地解释该对的行为:aux

首次运行(没有先前的aux文件):

\setcounter{numberofauthors}{0}
\emailauthor{[email protected]}{John Doe\fnref {fn1}}
\urlauthor{https://johndoe.com/}{John Doe\fnref {fn1}}
\setcounter{numberofauthors}{1}

第二次运行时,当计算和numberofauthors时计数器为 0 ,得出没有作者的电子邮件地址和 URL。第二次运行后(使用上述文件),文件包含:\emailauthor\urlauthorauxaux

\setcounter{numberofauthors}{1}
\emailauthor{[email protected]}{John Doe\fnref {fn1}}
\urlauthor{https://johndoe.com/}{John Doe\fnref {fn1}}
\setcounter{numberofauthors}{1}

这在后续运行中保持不变,从而产生了\emailauthor和的所需行为\urlauthor

相关内容