最近在撰写论文时,由于发现Zotero+Better BibTex导出参考文献时,会与Google Scholar上有诸多不一致,引起了很多不必要的麻烦,奈何网上关于如何自定义导出格式的教程寥寥无几,在查阅官方文档后,经过一番摸索,将最终的设置整理如下。
Better BibTex(官方文档)是针对文献管理工具Zotero所开发的一款插件,其主要功能为格式化所需要导出的参考文献citation keys以及自定义fields,其中的自定义功能可通过javascript实现,方便修改,并且功能强大。
例如,通常我们在导出参考文献时,都会在Google Scholar上进行引用,格式如下:
@inproceedings{he2016deep,
title={Deep residual learning for image recognition},
author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition},
pages={770--778},
year={2016}
}
但如果不进行处理,对于同样一篇论文,Zotero导出的格式却是:
@inproceedings{KaimingDeepResidual,
title = {Deep residual learning for image recognition},
author = {He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
year = {2016},
keywords = {/reading},
pages = {770--778},
file = {He et al_2016_Deep residual learning for image recognition.pdf:/xxx/file_location/...},
}
甚至有些参考文献会有很多不同之处,以及额外的我们不需要的filed。如果后期参考文献一多,一个一个修改就很麻烦,而Better BibTex正好完美解决这样一个问题。
在安装插件之后,选择Zotero->preference->Better BibTex->Export->postscript,在此处填入自定义代码即可。
Talk is shit, show me the code:
if (Translator.BetterTeX) {
if(tex.has['eventtitle']){
tex.add({
name: 'booktitle',
value: tex.has['eventtitle'].value
});
delete tex.has['eventtitle'];
}
if(tex.has['date']){
tex.add({
name: 'year',
value: tex.has['date'].value
});
delete tex.has['date'];
}
if(tex.has['journaltitle']){
tex.add({
name: 'journal',
value: tex.has['journaltitle'].value
})
delete tex.has['journaltitle'];
}
else if(tex.has['shortjournal']){
tex.add({
name: 'journal',
value: tex.has['shortjournal'].value
})
delete tex.has['shortjournal'];
}
delete tex.has['shortjournal'];
}
导出文献之前,右键点击选择Better BibTex->Refresh BibTex key。导出时选择使用Better BibTex导出即可。
效果:
@inproceedings{he2016deep,
title = {Deep Residual Learning for Image Recognition},
author = {He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
pages = {770--778},
booktitle = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
year = {2016}
}
与Google Scholar上别无二致。
上述代码需要一定的javascript基础,另外一些类对象的名称大家可以参照官方文档,有问题欢迎与我交流讨论。