编辑 BST 文件以正确消除同一年同一主要作者的歧义

编辑 BST 文件以正确消除同一年同一主要作者的歧义

我在用着生物信息学在 LaTeX 中引用论文。如果我有两篇引用,引用了同一作者发表于同一年的两篇不同论文,则引用在引文和参考书目中的格式正确,可以使用在年份后附加“a”和“b”来消除歧义:

例如,如果 .bib 文件包含:

@article{sumner2012a,
    author={Sumner, Jeremy G. and Fern{\'a}ndez-S{\'a}nchez, J. and Jarvis, P.D.},
    title={Lie Markov Models},
    year = {2012}
}

@article{sumner2012b,
    author={Sumner, Jeremy G. and Fern{\'a}ndez-S{\'a}nchez, J. and Jarvis, P.D.},
    title={Some other paper with exact same authors in same year},
    year = {2012}
}

我对这两篇论文的引用如下:

\citep{sumner2012a} \citep{sumner2012b}

引用以“a”和“b”正确显示,如下所示:

(Sumner et al., 2012a) (Sumner et al., 2012b)

并且参考书目也使用“a”和“b”正确格式化:

Sumner, J. G., Fernández-Sánchez, J., and Jarvis, P. (2012a).
    Lie markov models.
Sumner, J. G., Fernández-Sánchez, J., and Jarvis, P. (2012b).
    Some other paper with exact same authors in same year.

问题是,当主要作者是同一个人,年份也是同一个人时,次要作者不同。例如,如果 .bib 文件包含(相同的主要作者 Sumner 但不同的第二作者):

@article{sumner2012a,
    author = {Sumner, Jeremy G. and Jarvis, Peter D. and Fern{\'a}ndez-S{\'a}nchez, Jes{\'u}s and Kaine, Bodie T. and Woodhams, Michael D. and Holland, Barbara R.},
    title = {Is the General Time-Reversible Model Bad for Molecular Phylogenetics?},
    year = {2012}
}

@article{sumner2012b,
    author={Sumner, Jeremy G. and Fern{\'a}ndez-S{\'a}nchez, J. and Jarvis, P.D.},
    title={Lie Markov Models},
    year = {2012}
}

“a”和“b”字母没有出现,因此引用有歧义:

(Sumner et al., 2012) (Sumner et al., 2012)

Sumner, J. G., Fernández-Sánchez, J., and Jarvis, P. (2012).
    Lie Markov Models
Sumner, J. G., Jarvis, P. D., Fernández-Sánchez, J., Kaine, B. T., Woodhams, M. D., and Holland, B. R. (2012).
    Is the general time-reversible model bad for molecular phylogenetics?

我想我已经缩小了 BST 文件中打印年份和消歧字母的部分(称为 extra.label):

FUNCTION {output.year.check}
{ year empty$
    { "empty year in " cite$ * warning$ }
    { write$
      " (" year * extra.label * ")" *
      mid.sentence 'output.state :=
    }
  if$
}

可能还有这些功能:

FUNCTION {initialize.extra.label.stuff} 
{ #0 int.to.chr$ 'last.label :=
     "" 'next.extra :=
     #0 'last.extra.num :=
}

FUNCTION {forward.pass}
{ last.label label =
    { last.extra.num #1 + 'last.extra.num :=
      last.extra.num int.to.chr$ 'extra.label :=
    }
    { "a" chr.to.int$ 'last.extra.num :=
      "" 'extra.label :=
      label 'last.label :=
    }
  if$
}

FUNCTION {reverse.pass}       
{ next.extra "b" =
    { "a" 'extra.label := }
    'skip$
  if$
  label extra.label * "}" * 'label :=
  extra.label 'next.extra :=
}

EXECUTE {initialize.extra.label.stuff}

ITERATE {forward.pass}

REVERSE {reverse.pass}

但我完全不知道这段代码是如何工作的,也不知道如何修复这个错误。我本质上需要它在确定是否需要打印 extra.label 时仅检查第一个作者是否相同,而不是检查所有作者是否相同。有什么建议吗?

最小工作示例,演示什么有效(Tumner)和什么无效(Sumner)。类文件来自http://www.biometrics.tibs.org/biom.cls.txt

\documentclass[useAMS,usenatbib]{biom}

\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{sumner2012a,
author = {Sumner, Jeremy G. and Jarvis, Peter D. and Fern{\'a}ndez-S{\'a}nchez, Jes{\'u}s and Kaine, Bodie T. and Woodhams, Michael D. and Holland, Barbara R.},
title = {Is the General Time-Reversible Model Bad for Molecular Phylogenetics?},
year = {2012}
}
@article{sumner2012b,
    author={Sumner, Jeremy G. and Fern{\'a}ndez-S{\'a}nchez, J. and Jarvis, P.D.},
    title={Some other paper with exact same authors in same year},
    year = {2012}
}
@article{tumner2013c,
author = {Tumner, Jeremy G. and Jarvis, Peter D.},
title = {Is the General Time-Reversible Model Bad for Molecular Phylogenetics?},
year = {2013}
}
@article{tumner2013d,
    author={Tumner, Jeremy G. and Jarvis, Peter D.},
    title={Some other paper with exact same authors in same year},
    year = {2013}
}
\end{filecontents}

\title[Title]{Title}
\author{Jane Author$^*$\email{[email protected]}}
\begin{document}
\date{{\it Received June} 2018. {\it Revised October} 2018.  {\it
Accepted December} 2018.}
\pagerange{\pageref{firstpage}--\pageref{lastpage}} 
\volume{100}
\pubyear{2018}
\artmonth{December}
\doi{10.1111/j.1541-0420.2005.00454.x}

\begin{abstract}
Abstract
\end{abstract}

\maketitle
\label{firstpage}
\section{Introduction}

\citep{sumner2012a} \citep{sumner2012b}
\citep{tumner2013c} \citep{tumner2013d}

\backmatter

\bibliographystyle{biom}
\bibliography{biblio}

\label{lastpage}

\end{document}

在此处输入图片描述

答案1

这可能很简单,只需注释掉以下行即可biom.bst

  "\protect\citeauthoryear{" author my.full.label * "}{" * swap$ * "}{" 

并取消注释以下行:

  "\protect\citeauthoryear{" author format.lab.names * "}{" * swap$ * "}{" 

这两行作为函数的一部分出现calc.labelbiom.bst

FUNCTION {calc.label}      
{ type$ "book" =
  type$ "inbook" =
  or
    'author.editor.key.label
    { type$ "proceedings" =
        'editor.key.label                       
        'author.key.label                       
      if$
    }
  if$
%  "\protect\citeauthoryear{" author my.full.label * "}{" * swap$ * "}{"                    
  "\protect\citeauthoryear{" author format.lab.names * "}{" * swap$ * "}{"                    
%  "\protect\citeauthoryear{" format.authors * "}{" * swap$ * "}{"                    
%  "\protect\citeauthoryear{" swap$ * "}{"                   
  *                                                     
  year field.or.null purify$ #-1 #4 substring$          
  *                       
  'label :=
} 

就这样,MWE 重复了上面的内容

\documentclass[useAMS,usenatbib]{biom}

\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{sumner2012a,
author = {Sumner, Jeremy G. and Jarvis, Peter D. and Fern{\'a}ndez-S{\'a}nchez, Jes{\'u}s and Kaine, Bodie T. and Woodhams, Michael D. and Holland, Barbara R.},
title = {Is the General Time-Reversible Model Bad for Molecular Phylogenetics?},
year = {2012}
}
@article{sumner2012b,
    author={Sumner, Jeremy G. and Fern{\'a}ndez-S{\'a}nchez, J. and Jarvis, P.D.},
    title={Some other paper with exact same authors in same year},
    year = {2012}
}
@article{tumner2013c,
author = {Tumner, Jeremy G. and Jarvis, Peter D.},
title = {Is the General Time-Reversible Model Bad for Molecular Phylogenetics?},
year = {2013}
}
@article{tumner2013d,
    author={Tumner, Jeremy G. and Jarvis, Peter D.},
    title={Some other paper with exact same authors in same year},
    year = {2013}
}
\end{filecontents}

\title[Title]{Title}
\author{Jane Author$^*$\email{[email protected]}}
\begin{document}
\date{{\it Received June} 2018. {\it Revised October} 2018.  {\it
Accepted December} 2018.}
\pagerange{\pageref{firstpage}--\pageref{lastpage}} 
\volume{100}
\pubyear{2018}
\artmonth{December}
\doi{10.1111/j.1541-0420.2005.00454.x}

\begin{abstract}
Abstract
\end{abstract}

\maketitle
\label{firstpage}
\section{Introduction}

\citep{sumner2012a} \citep{sumner2012b}
\citep{tumner2013c} \citep{tumner2013d}

\backmatter

\bibliographystyle{biom}
\bibliography{biblio}

\label{lastpage}

\end{document}

产生了似乎正确的输出,但我不知道它是否会破坏其他东西:

在此处输入图片描述

相关内容