从 bst 文件自定义参考书目作者姓名

从 bst 文件自定义参考书目作者姓名

我在用着参考书目样式问题。我喜欢它的一点是它(几乎)不显示作者的姓名首字母,而这正是我想要的。但是,如果参考文献只有一位作者,它会显示姓名首字母。此外,如果参考文献有两位作者,我希望它在参考文献列表(本例中为段落)中显示为 Author1 和 Author2。

为了解决这个问题,我编辑了 bst 文件,特别是FUNCTION {format.names}在第 396 行,以便

  1. 如果参考文献有超过 2 位作者,则显示为 Author1 et al.
  2. 如果参考文献有 2 位作者,则显示为 Author1 & Author2
  3. 如果参考文献有 1 位作者,则显示为 Author1
  4. 在所有情况下均不带首字母。

这是编辑的功能:

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=                
  s num.names$ 'numnames :=     
  numnames 'namesleft :=        
    { namesleft #0 > }
    { s nameptr "{vv~}{ll}{, jj}" format.name$ 
    't :=

numnames #2 >
    {
      nameptr #1 >
        {
          nameptr #2 =
            {
              " {et~al.}" *
            }
            {
                nameptr #2 >
                { "" * }
                { ", " * t * }
                if$
            }
            if$

        }
        't
      if$
    }
    {
      nameptr #1 >
        {
          namesleft #1 >
            { ", " * t * }
            {
              numnames #2 >
                { "," * }
                'skip$
              if$
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
              t "others" =
                {
                  " {et~al.}" *
                }
                { " \& " * t * }
              if$
            }
          if$
        }
        't
      if$
    } if$

      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

效果很好在上述情况 2 和 3 中,作者末尾有一个点 (.)

这是从上面链接的问题中获取的 MWE。

\documentclass{article}

\bibliographystyle{apj_w_etal_3auth}

\usepackage[super,sort&compress]{natbib}

\usepackage{paralist}

\renewenvironment{thebibliography}[1]{%
\textsc{\textbf{References:}}
\let\par\relax\let\newblock\relax%
\inparaitem[{[}1{]}]}{\endinparaitem}

\usepackage{times}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@lbibitem}{\item[\hfil\NAT@anchor{#2}{\NAT@num}]}{\item[\NAT@anchor{#2}{\NAT@num}]}{}{}
\makeatother

\begin{filecontents}{test.bib}
@article{einstein,
    author =       "Albert Einstein",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
        [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    volume =       "322",
    number =       "10",
    pages =        "891--921",
    year =         "1905",
    DOI =          "http://dx.doi.org/10.1002/andp.19053221004"
}

@book{latexcompanion,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The \LaTeX\ Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}

@article{belloche2014detection,
  title={Detection of a branched alkyl molecule in the interstellar medium: iso-propyl cyanide},
  author={Belloche, Arnaud and Garrod, Robin T and M{\"u}ller, Holger SP and Menten, Karl M},
  journal={Science},
  volume={345},
  number={6204},
  pages={1584--1587},
  year={2014},
  publisher={American Association for the Advancement of Science}
}

@article{mcnally1989anxiety,
  title={Is anxiety sensitivity distinguishable from trait anxiety? Reply to Lilienfeld, Jacob, and Turner (1989).},
  journal={Nature},
  author={McNally, Richard J and McLovin, Just},
  year={1989},
  publisher={American Psychological Association}
}

\end{filecontents}

\begin{document}

\nocite{*}

\bibliography{test}

% \show\bibitem

% \makeatletter
% \show\@lbibitem
% \makeatother

\end{document}

如何去除这个恼人的点?请参见下图中的第一个和最后一个参考

参考图

相关内容