之前修改的忘记了,浪费了很多时间,latex模板上没有给出需要的格式,浅浅修改一下。。。。
bst格式文件包含参考文献格式,需要与tex文件在同一文件夹下,并且正文中插入参考文献时
\documentclass[iicol]{sn-jnl}%%zhengwen Math and Physical
\usepackage{natbib}%%需要这个命令
\bibliographystyle{sn-mathphys-numxiu}%这个是后续需要修改的bst文件
\bibliography{sample}%sample是bib文件
要修改参考文献列表条目按第一作者的姓氏字母顺序排列,需调整BibTeX样式文件(bmc-mathphys.bst)中的排序逻辑。具体步骤如下:
- 修改 sort.format.names 函数
目标:仅提取第一个作者的姓氏进行排序。
找到原函数:
FUNCTION {sort.format.names}
{ 's :=
#1 'nameptr :=
""
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ nameptr #1 >
{ " " *
"alpha" is.in.list
'skip$
{numnames int.to.str$ * " " *}
if$
}
'skip$
if$
s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
nameptr numnames =
t "others" =
and
{ "et al" * }
{ t sortify * }
if$
#3 numnames <
"alpha" is.in.list not
and
{#0 'namesleft :=
" zzz " *
}
{
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
if$
}
while$
}
修改后:
FUNCTION {sort.format.names}
{ 's :=
#1 'nameptr :=
s num.names$ 'numnames :=
s nameptr "{vv{ } }{ll{ }}" format.name$ 't := % 仅提取姓氏和前缀
t sortify % 转换为排序格式
}
- 修改 presort 函数
目标:使排序键仅基于作者(或editor/organization)信息。
找到原函数中的排序键生成部分:
在这里插入代码片
FUNCTION {presort}
{ …
" "
*
type$ “book” =
type$ “inbook” =
or
{author empty$
'editor.organization.sort
'author.organization.sort
if$
}
{ type$ “proceedings” =
type$ “incollection” =
or
{author empty$
'editor.organization.sort
'author.organization.sort
if$
}
{ type$ “manual” =
'author.organization.sort
'author.sort
if$
}
if$
}
if$
" "
*
year field.or.null sortify
*
" "
*
title field.or.null
sort.format.title
*
#1 entry.max$ substring$ 'sort.label :=
sort.label *
#1 entry.max$ substring$ 'sort.key$ :=
…
}
修改后:
FUNCTION {presort}
{ calc.label
author empty$
{ editor empty$
{ organization empty$
{ key empty$
{ "zzz" }
{ key sortify }
if$
}
{ "The " #4 organization chop.word sortify }
if$
}
{ editor sort.format.names }
if$
}
{ author sort.format.names }
if$
'sort.key$ :=
}
- 确保次级排序条件(可选)
若需在作者相同的情况下按年份或标题排序,可保留相关代码。但根据要求“其他条件不变”,此处省略。
修改后的效果
排序逻辑:仅按第一作者的姓氏字母顺序排列。
处理无作者情况:依次使用editor、organization、key作为排序依据。
格式不变:参考文献条目格式保持原有样式,仅调整排序顺序。
验证步骤
使用修改后的.bst文件编译LaTeX文档。
检查生成的参考文献列表是否严格按第一作者的姓氏字母顺序排列。
确保无作者条目(如组织报告)按预定逻辑排序。
通过上述修改,参考文献列表将按第一作者的姓氏字母顺序排列,同时保持其他格式要求不变。