有时,在引用参考文献时,我想在打印的参考文献中添加注释。我对 biblatex 有足够的了解,一旦注释进入引用记录(例如注释字段),就可以打印注释。但是,由于注释实际上不是所引用参考文献的一般属性,而是与引用它的特定上下文有关,因此我不想将注释添加到参考书目数据库,例如将注释添加到文件.bib
。相反,我想从我的 LaTeX 文档中添加该数据。biblatex 灵活的数据模型肯定有办法做到这一点?
编辑:为了符合始终有一个 MWE(B),即使它实际上只是最基本的 biblatex 模板的副本:
\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{key,
author = {Author, A.},
year = {2001},
title = {Title},
publisher = {Publisher},
}
\end{filecontents}
\newcommand\notecite[2]{%
\cite{#1}%
% some magic biblatex to set note field in record
% corresponding to key #1 to #2
}
\begin{document}
\notecite{key}{That is what we're talking about!}
\printbibliography
\end{document}
问题是,要注入什么魔法\notecite
。
答案1
我认为你不能为此使用源映射,因为源映射是在阶段biber
而不是LaTeX
阶段完成的。
那这个呢?
\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{key1,
author = {AuthorA, A.},
year = {2001},
title = {Title1},
publisher = {Publisher1},
}
@book{key2,
author = {AuthorB, A.},
year = {2001},
title = {Title2},
publisher = {Publisher2},
}
\end{filecontents}
\makeatletter
\newcommand\citewithnote[2]{%
\csdef{abx@field@note@#1}{#2}%
\cite{#1}%
}
\AtEveryBibitem{%
\ifcsdef{abx@field@note@\thefield{entrykey}}
{\def\abx@field@note{\csuse{abx@field@note@\thefield{entrykey}}}}{}%
}
\makeatother
\pagestyle{empty}
\begin{document}
\citewithnote{key1}{That is what we're talking about!}
\citewithnote{key2}{A different note}
\printbibliography
\end{document}