我正在对从 Bookends 导出的文件使用biber
和。这种方法大部分情况下都很好用。不过,我有一些期刊文章,由于各种原因,它们的和字段最终都相同。我想做一个地图,检查和是否相同,如果相同,则省略该字段。BibLaTeX
.bib
journal
shortjournal
journal
shortjournal
shortjournal
以下是示例条目:
@Article{Larsen1977,
author = {Larsen, Mogens Trolle},
title = {Partnerships in the Old Assyrian Trade},
journal = {Iraq},
shortjournal = {Iraq},
volume = {39},
number = {1},
pages = {119--145},
year = {1977}}
答案1
理想情况下,应该在导出端修复此问题.bib
。根据您的实际使用情况,shortjournal
可能根本不需要消除这些情况。
这是一个可以做到这一点的源图,
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear]{biblatex}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=journal, fieldtarget=journaltitle]
}
\map{
\step[fieldsource=journaltitle, match=\regexp{\A(.*)\Z}, final]
\step[fieldsource=shortjournal, match=\regexp{\A$1\Z}, final]
\step[fieldset=shortjournal, null]
}
}
}
\begin{filecontents}{\jobname.bib}
@article{Larsen1977,
author = {Larsen, Mogens Trolle},
title = {Partnerships in the Old Assyrian Trade},
journal = {Iraq},
shortjournal = {Iraq},
volume = {39},
number = {1},
pages = {119--145},
year = {1977},
}
@article{test2,
author = {John Tumble},
title = {A Tremendously Interesting Idea},
journal = {Journal of Tremendously Interesting Ideas},
shortjournal = {JTII},
volume = {1},
number = {1},
year = {1946},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
Lorem \autocite{sigfridsson,Larsen1977,test2}
\printbiblist{shortjournal}
\printbibliography
\end{document}