数据模型宏不能在序言中使用

数据模型宏不能在序言中使用

我在用着回答使用 创建带注释的参考书目biblatex,代码如下:

\documentclass{article}

% This just makes a dummy bib file
\begin{filecontents}{\jobname.bib}
@ARTICLE{a,
   author = {Doe, J.},
   title = {The Title},
   journal = {The Journal},
   mynote = {This source is really interesting because it doesn't have a real title}
}

@ARTICLE{b,
   author = {Smith, J.},
   title = {The New Title},
   journal = {The Same Journal},
   mynote = {This second source is also really interesting because it contains words}
}
\end{filecontents}

% This does the work
\usepackage[style=trad-plain]{biblatex}
\addbibresource{\jobname.bib}
\DeclareDatamodelFields[type=field,datatype=literal]{mynote}

\usepackage{xpatch}
\xapptobibmacro{finentry}{\par\printfield{mynote}}{}{}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

然而,我收到警告

包 biblatex 警告:数据模型宏“DeclareDatamodelFields”不能在序言中使用。

并且输出就像没有对数据模型进行任何更改一样:

图像

答案1

从 2.9 版开始biblatex这次提交)数据模型宏(如,,,\DeclareDatamodelEntrytypes...完整列表可在§4.5.3中找到DeclareDatamodelFields\DeclareDatamodelEntryfields数据模型规范,第 156-161 页biblatex文档)在序言中被禁用,并且只产生一条警告,如下所示

数据模型宏'\DeclareDatamodelFields'不能在序言中使用

.dbx这些命令现在只能从外部(数据模型)文件中使用。

解决方案是将这些数据模型宏移动到外部.dbx文件。

在我们的示例中,我们将调用所述文件mynote.dbx,并且只有一行需要移动

\DeclareDatamodelFields[type=field,datatype=literal]{mynote}

datamodel=mynote然后我们通过选项调用这个数据模型biblatex

平均能量损失

\documentclass{article}

% This just makes a dummy bib file
\begin{filecontents}{\jobname.bib}
@ARTICLE{a,
   author = {Doe, J.},
   title = {The Title},
   journal = {The Journal},
   mynote = {This source is really interesting because it doesn't have a real title}
}

@ARTICLE{b,
   author = {Smith, J.},
   title = {The New Title},
   journal = {The Same Journal},
   mynote = {This second source is also really interesting because it contains words}
}
\end{filecontents}

% This does the work
\usepackage[style=trad-plain,datamodel=mynote]{biblatex}
\addbibresource{\jobname.bib}


\usepackage{xpatch}
\xapptobibmacro{finentry}{\setunit{\par}\printfield{mynote}}{}{}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

如果mynote.dbx只是

\DeclareDatamodelFields[type=field,datatype=literal]{mynote}

相关内容