在使用 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
将\emailauthor
和urlauthor
命令写入aux
文件,然后在文档开头读取并执行这些命令,定义@elseads
和@elsuads
宏以分别包含作者的电子邮件地址和网址。通过对进行一些修改elsarticle.cls
,我们可以重新定义\emailauthor
和\urlauthor
以排除作者姓名(如果只有一个)。这些命令通过新的计数器来评估作者的数量numberofauthors
,其值写入前文件中的和\emailauthor
命令。\urlauthor
aux
步骤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:将其保存numberofauthors
在aux
文件中。
这是通过
\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
\urlauthor
aux
aux
\setcounter{numberofauthors}{1}
\emailauthor{[email protected]}{John Doe\fnref {fn1}}
\urlauthor{https://johndoe.com/}{John Doe\fnref {fn1}}
\setcounter{numberofauthors}{1}
这在后续运行中保持不变,从而产生了\emailauthor
和的所需行为\urlauthor
。