为一个自然样式文档,我想在章节后打印参考文献,但前提是它们之前没有打印过。我目前使用这种技术:
\documentclass{article}
\usepackage[american,english]{babel}
\usepackage[babel]{csquotes}
\usepackage[style=nature,hyperref,autocite=superscript]{biblatex}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}
\begin{document}
\begin{refsegment}
Main text\autocite{angenendt,bertram}.
\end{refsegment}
\printbibliography[heading=bibintoc,segment=1]
Other info\autocite{bertram,gillies}.
\defbibfilter{not_printed_before}{ ( not segment=1 ) and segment=0 }
\printbibliography[heading=none,filter=not_printed_before]
\end{document}
这正确地避免了bertram
第二次打印。但是,如果涉及更多段,这会变得很麻烦。有没有一种自动方法来检查参考文献是否之前已经打印过?
答案1
哦哦。我想我几乎可以做到这一点!请注意,你需要一个refsegment
for all 才能使我打印迄今为止最大段的方法起作用。
\documentclass{article}
\usepackage[style=nature,autocite=superscript]{biblatex}
\addbibresource{biblatex-examples.bib}
\pagestyle{empty}
\makeatletter
\def\blx@skipprinted{}% define a list to hold entries to be skipped
\def\addskipprinted#1{% macro to add an entry to our list
\edef\X{%
\noexpand\iffieldequalstr{entrykey}{#1}
{\noexpand\toggletrue{blx@skipentry}}
{}}%
\expandafter\g@addto@macro\expandafter\blx@skipprinted\expandafter{\X}}
\AtEveryBibitem{\addskipprinted{\thefield{entrykey}}}% add every item to the list
\defbibcheck{skipprinted}{% a check for our list
\blx@skipprinted}
\AtBeginBibliography{%
% run our check in the bibliography
\blx@key@bibcheck{skipprinted}%
% print bibliography for max segment so far
\blx@key@segment{\the\csname blx@maxsegment@\the\c@refsection\endcsname}}
\makeatother
\begin{document}
\begin{refsegment}
Main text\autocite{angenendt,bertram}.
\end{refsegment}
\printbibliography[heading=bibintoc]
\begin{refsegment}
Other info\autocite{bertram,gillies}.
\end{refsegment}
\printbibliography[heading=none]
\begin{refsegment}
Other info\autocite{gillies,glashow}.
\end{refsegment}
\printbibliography[heading=none]
\end{document}