代码1:
FUNCTION {format.names}
{ 'bibinfo :=
duplicate$ empty$ 'skip$ {
's :=
"" 't :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr
"{vv~}{ll}{, ff}{, jj}"
format.name$ 't :=
nameptr #1 >
{
nameptr #1 = numnames #2 > and
{ "," * }
'skip$
if$
t "others" =
{
" et al." *
't := % 如果遇到 "others" 则直接跳过后续操作
}
{
namesleft #1 >
{ ", " * }
'skip$
if$
t
nameptr #1 >
{
nameptr #1 = numnames #2 > and
{ " \& " * } % 最后两个作者之间用 & 连接
{ ", " * }
if$
}
't
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
} if$
}
运行结果:即,有的有缩写,有的没有。
author={Qi, Ning and Zhang, Ao},(无缩写的)
author={Shan, S. N. and Zhang, Z. C. and Ji, W. Y. and Wang, H.},(有缩写但是只显示2个作者)
基本全错。
代码2:
FUNCTION {format.names}
{ 'bibinfo :=
duplicate$ empty$ 'skip$ {
's :=
"" 't :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr
"{vv~}{ll}{ f{}}{jj}"
format.name$ 't :=
nameptr #1 >
{
nameptr #3
#1 + =
numnames #3
> and
{ #3 'numnames := } % 修改此处以保证显示所有作者
'skip$
if$
nameptr #1 >
{
", " * % 每个作者之间用逗号分隔
t
nameptr numnames = % 如果是最后一个作者
{ " \& " * } % 最后一个作者之前用 & 连接
{ }
if$
t "others" = % 如果是 "others" 则显示 et al.
{ " et al." * }
{ t * }
if$
}
't
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
} if$
}
运行结果:
也很奇怪,有一些是有连词“&”,但是老重复是什么意思呢。
FUNCTION {format.names}
{ 'bibinfo :=
duplicate$ empty$ 'skip$ {
's :=
"" 't :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr
"{vv~}{ll}{ f{}}{jj}"
format.name$ 't :=
nameptr #1 >
{
nameptr #3
#1 + =
numnames #3
> and
{ "others" 't :=
#1 'namesleft := }
'skip$
if$
namesleft #1 >
{ ", " * t * }
{
"," *
s nameptr "{ll}" format.name$ duplicate$ "others" =
{ 't := }
{ pop$ }
if$
t "others" =
{
" " * bbl.etal *
}
{ " " * t * }
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
} if$
}
这个没缩写“."和&,但是作者名字啥的都是对的。