![如果另一个字段为空,使用 biblatex 将字段值从一个字段复制到另一个字段](https://linux22.com/image/459407/%E5%A6%82%E6%9E%9C%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%AD%97%E6%AE%B5%E4%B8%BA%E7%A9%BA%EF%BC%8C%E4%BD%BF%E7%94%A8%20biblatex%20%E5%B0%86%E5%AD%97%E6%AE%B5%E5%80%BC%E4%BB%8E%E4%B8%80%E4%B8%AA%E5%AD%97%E6%AE%B5%E5%A4%8D%E5%88%B6%E5%88%B0%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%AD%97%E6%AE%B5.png)
我使用了一个设置,其中有一个字段 authauthor,其中包含应该显示在作者索引中的作者的标准名称。从 biblatex 中索引的另一个字段获取名称我也想使用 authauthor 的值进行排序。因此,我正在寻找可以检查文件 sortname 是否有值的方法,如果没有但 authauthor 有值,则将 authauthor 的值复制到 sortname。可以用 biblatex 来实现吗?
\documentclass{scrbook}
\usepackage[
natbib=true,
style=langsci-unified,
citestyle=langsci-unified,
datamodel=langsci, % add authauthor and autheditor as possible fields to bibtex entries
backend=biber,
indexing=cite
]{biblatex}
\begin{filecontents}{bibliography.bib}
@incollection{Steedman89,
authauthor = {Mark Steedman},
author = {Steedman, Mark J.},
pages = {463--504},
sortname = {Mark Steedman},
address = {Cambridge},
booktitle = {Lexical Representation and Process},
editor = {Marslen-Wilson, William},
publisher = {The MIT Press},
title = {Lexical Representation and Process},
year = {1989},
title = {Grammar, Interpretation, and Processing from the Lexicon}}
@incollection{Steedman90,
authauthor = {Mark Steedman},
author = {Steedman, Mark J.},
pages = {463--504},
%sortname = {Mark Steedman},
address = {Cambridge},
booktitle = {Lexical Representation and Process},
editor = {Marslen-Wilson, William},
publisher = {The MIT Press},
title = {Lexical Representation and Process},
year = {1990},
title = {Grammar, Interpretation, and Processing from the Lexicon}}
@incollection{Steedman91,
authauthor = {Mark Steedman},
author = {Steedman, Mark J.},
pages = {463--504},
sortname = {Mark Steedman},
address = {Cambridge},
booktitle = {Lexical Representation and Process},
editor = {Marslen-Wilson, William},
publisher = {The MIT Press},
title = {Lexical Representation and Process},
year = {1991},
title = {Grammar, Interpretation, and Processing from the Lexicon}}
\end{filecontents}
\addbibresource{bibliography.bib}
\begin{document}
\citep{Steedman89,Steedman90,Steedman91}
\printbibliography
\end{document}
示例显示,如果在第二个条目中注释掉字段 sortname,则此项排序错误。sortname 应该以某种方式从 authauthor 接管。
答案1
您可以使用 Biber sourcemap 将一个字段的值复制到另一个字段。一个这样的示例(其中第一个字段也被删除)是如何将字段注释移至参考文献末尾。
但是,在您的用例中,这对我来说似乎没有必要。将authauthor
和添加autheditor
到排序方案中可能更容易。然后您不再需要将其值复制到sortname
。
\documentclass{article}
\usepackage[
natbib=true,
style=langsci-unified,
datamodel=langsci, % add authauthor and autheditor as possible fields to bibtex entries
backend=biber,
indexing=cite
]{biblatex}
\DeclareSortingTemplate{nyt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sortname}
\field{authauthor}
\field{author}
\field{autheditor}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{volume}
\literal{0}
}
}
\begin{filecontents}{\jobname.bib}
@incollection{Steedman89,
authauthor = {Mark Steedman},
author = {Steedman, Mark J.},
pages = {463--504},
sortname = {Mark Steedman},
address = {Cambridge},
booktitle = {Lexical Representation and Process},
editor = {Marslen-Wilson, William},
publisher = {The MIT Press},
title = {Lexical Representation and Process},
year = {1989},
title = {Grammar, Interpretation, and Processing from the Lexicon}}
@incollection{Steedman90,
authauthor = {Mark Steedman},
author = {Steedman, Mark J.},
pages = {463--504},
%sortname = {Mark Steedman},
address = {Cambridge},
booktitle = {Lexical Representation and Process},
editor = {Marslen-Wilson, William},
publisher = {The MIT Press},
title = {Lexical Representation and Process},
year = {1990},
title = {Grammar, Interpretation, and Processing from the Lexicon}}
@incollection{Steedman91,
authauthor = {Mark Steedman},
author = {Steedman, Mark J.},
pages = {463--504},
sortname = {Mark Steedman},
address = {Cambridge},
booktitle = {Lexical Representation and Process},
editor = {Marslen-Wilson, William},
publisher = {The MIT Press},
title = {Lexical Representation and Process},
year = {1991},
title = {Grammar, Interpretation, and Processing from the Lexicon}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\citep{Steedman89,Steedman90,Steedman91}
\printbibliography
\end{document}