假设我有两个 .tex 文件,每个文件都必须有一个参考书目。但是,我希望第二个文件中的参考书目包含仅有的不在第一个中的引用。例如:
\documentclass[11pt, a4paper]{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,natbib=true,backend=biber,maxbibnames=99,url=false]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\bibliography{test}
\begin{document}
This is test file 1 \citep{Tversky:Kahneman:1990,Tversky:Kahneman:1974}
\printbibliography
\end{document}
第一个文件引用了两个来源。
这是第二个文件:
\documentclass[11pt, a4paper]{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,natbib=true,backend=biber,maxbibnames=99,url=false]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\bibliography{test}
\begin{document}
This is test file 2 \citep{Tversky:Kahneman:1990,Kahneman:1973}
\printbibliography
\end{document}
请注意,此 tex 文档引用了两个来源:一个在第一个文档中被引用,另一个没有被引用。我希望此处的参考部分包括仅有的 Kahneman:1973
,因为Tversky:Kahneman:1990
包含在第一个中。
test.bib
如果您想编译上述文件,这是我的……
@book{Kahneman:1973,
author = {Kahneman, D.},
title = {Attention and effort},
publisher = {Prentice-Hall},
year = {1973},
address = {Englewood Cliffs, NJ},
confidential = {n}
}
@article{Tversky:Kahneman:1974,
author = {Tversky, A. and Kahneman, D.},
title = {Judgment under Uncertainty: {H}euristics and Biases},
journal = {Science},
year = {1974},
volume = {185},
number = {4157},
pages = {1124-1131},
note = {10.1126/science.185.4157.1124},
confidential = {n}
}
@incollection{Tversky:Kahneman:1990,
author = {Tversky, A. and Kahneman, D.},
title = {Judgements under uncertainty: {H}euristics and Biases},
booktitle = {Rationality in action: {C}ontemporary approaches.},
publisher = {Cambridge University Press},
year = {1990},
pages = {171-188},
editor = {Moser, Paul K.},
address = {New York},
confidential = {n}
}
有办法实现这个吗?我正在用latexmk
它来编译我的文档。我也愿意使用额外的脚本来实现它。谢谢!
答案1
我们可以使用类似的策略来按照在另一个文件中出现的顺序引用参考文献。
我们再次将另一个文档(示例中的第一个文件\jobname-ext
)导入到包装在 中的保存框中refsegment
。现在我们只需要从该段中过滤出这些条目并丢弃它们,这可以通过onlynew
过滤器完成,就像在使用 biblatex 的多个参考列表:如何删除重复的条目?。
第二个文件(在示例中\jobname
)将具有以下文档环境
\begin{document}
\importcites{\jobname-ext}
This is test file 2 \cite{sigfridsson,worman}
\printbibliography[filter=onlynew]
\end{document}
平均能量损失
\documentclass[british]{scrartcl}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=numeric,backend=biber,sorting=none,backref=true,defernumbers=true]{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage{docmute}
\usepackage{filecontents}
\begin{filecontents*}{\jobname-ext.tex}
\documentclass[british]{scrartcl}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=numeric,backend=biber,sorting=none]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
This is test file 1 \cite{sigfridsson,geer}
\printbibliography
\end{document}
\end{filecontents*}
\makeatletter
\defbibenvironment{plainimport}{}{}{}
\newsavebox{\importbox}
\newcommand{\importcites}[1]{%
\sbox\importbox{\vbox{%
\citetrackerfalse
\begin{refsegment}
\defbibfilter{onlynew}{not segment=\therefsegment}
\input{#1}
\let\blx@anchor\@empty
\printbibliography[env=plainimport,segment=\therefsegment]
\end{refsegment}}}}
\makeatother
\begin{document}
\importcites{\jobname-ext}
This is test file 2 \cite{sigfridsson,worman}
\printbibliography[filter=onlynew]
\end{document}