zotero better bibtex 限制输出作者数量
修改方法
- 工具
- better bibtex
- 打开 better bibtex首选项
- 导出
- postscript
在 postscript 里面,添加下述内容
如果只想删除掉多的作者
if (Translator.BetterTeX) {
// 限制最大输出作者数量
if (tex.has['author']) {
if (this.item.creators && this.item.creators.length > 7) {
/* pick the first 5 */
this.item.creators = this.item.creators.slice(0, 5);
this.addCreators();
}
}
}
如果需要在去除多的作者的时候,在最后面加上 and others 能让latex 自动生成 et al
if (Translator.BetterTeX) {
if (tex.has['author'] && this.item.creators && this.item.creators.length > 7) {
// 获取前5位作者的名字
const authors = this.item.creators.slice(0, 5).map(creator => {
if (creator.lastName && creator.firstName) {
return `${creator.lastName}, ${creator.firstName}`;
}
return creator.lastName || creator.name || '';
}).join(' and ');
// 重新设置 author 字段,添加 "and others"
tex.add({ name: 'author', value: authors + ' and others', replace: true });
}
}