我有一个大型.bib
数据库,其中许多条目都shorthands
定义了字段。
当我想将这些简写的使用限制在引用最多的文本时,我通常会将参考书目数据库的副本创建到工作目录,然后删除不需要的简写或将字段更改为类似的内容XXXshorthand
,以便将其从 bibtex/biber 中隐藏起来。
现在我想使该过程自动化。我设想了两种实现该目标的方法:
我可以在序言中设置类似
\includeonly
命令的东西,添加允许使用简写的条目(我不知道是否可能或如何做到这一点,但它会检查 bib 条目是否等于列出的条目,如果不相等,则向\clearfield{shorthand}
它们添加)。一种非常不同的方法,但可能比此更通用,即检查给定的条目是否被引用超过三次或五次(可由用户定义),如果是,则允许它使用其简写。
所以问题是这是否可能,如果可能,如何可能?
编辑
按照@ienissei的评论,它指出@lockstep 的回答,到目前为止,我已经能够忽略shorthandintro
(打印字符串citedas
— 英文为“从今以后引用为......” — 和第一个引用中的简写)并使后续引用(最多三个)忽略简写并使用 bibmacro cite:short
。
这是我迄今为止所做工作的 MWE,绘制在所提及的答案提供的 MWE 的顶部:
\documentclass{article}
\usepackage[style=verbose-trad3,citecounter=true]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
shorthand = {AL},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
shorthand = {BR},
}
\end{filecontents}
\addbibresource{\jobname.bib}
% Command to tell how much citations activate the use of shorthands
\newcommand{\shthreshold}[1]{\newcommand{\SHthreshold}{#1}}
\shthreshold{3}
\renewbibmacro*{cite}{%
\usebibmacro{cite:citepages}%
\global\togglefalse{cbx:loccit}%
\ifciteseen
{\ifciteibid
{\ifloccit
{\usebibmacro{cite:ibid}}
{\iffieldundef{shorthand}
{\usebibmacro{cite:opcit}}
{\ifnumgreater{\value{citecounter}}{\SHthreshold}%
{\usebibmacro{cite:shorthand}}
{\usebibmacro{cite:short}}}}}
{\iffieldundef{shorthand}
{\usebibmacro{cite:short}}
{\usebibmacro{cite:shorthand}}}}
{\usebibmacro{cite:full}}}
\renewbibmacro*{cite:full}{%
\usebibmacro{cite:full:citepages}%
\printtext[bibhypertarget]{%
\usedriver
{\DeclareNameAlias{sortname}{default}}
{\thefield{entrytype}}}%
\ifnumgreater{\value{citecounter}}{\SHthreshold}{
\usebibmacro{shorthandintro}}{}}
\begin{document}
\printshorthands
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}.
Some text \autocite{A01}. Some text \autocite{A01}. Some text \autocite{A01}.
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}.
\printbibliography
\end{document}
它运行得很好,除了它仍然打印简写列表中的条目。
编辑2:我修改了代码,因为它无法处理没有简写的条目。问题出在\iffieldundef{shorthand}
。
答案1
定义一个合适的书目类别并在 中使用它\printshorthands
。这与我的回答非常相似如何将参考书目分为“引用的作品”和“未引用的作品”?。
\documentclass{article}
\usepackage[style=verbose-trad3,citecounter=true]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
shorthand = {AL},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
shorthand = {BR},
}
\end{filecontents}
\addbibresource{\jobname.bib}
% Command to tell how much citations activate the use of shorthands
\newcommand{\shthreshold}[1]{\newcommand{\SHthreshold}{#1}}
\shthreshold{3}
\renewbibmacro*{cite}{%
\usebibmacro{cite:citepages}%
\global\togglefalse{cbx:loccit}%
\ifciteseen
{\ifciteibid
{\ifloccit
{\usebibmacro{cite:ibid}}
{\iffieldundef{shorthand}
{\usebibmacro{cite:opcit}}
{\ifnumgreater{\value{citecounter}}{\SHthreshold}%
{\usebibmacro{cite:shorthand}}
{\usebibmacro{cite:short}}}}}
{\iffieldundef{shorthand}
{\usebibmacro{cite:short}}
{\usebibmacro{cite:shorthand}}}}
{\usebibmacro{cite:full}}}
\renewbibmacro*{cite:full}{%
\usebibmacro{cite:full:citepages}%
\printtext[bibhypertarget]{%
\usedriver
{\DeclareNameAlias{sortname}{default}}
{\thefield{entrytype}}}%
\ifnumgreater{\value{citecounter}}{\SHthreshold}{
\usebibmacro{shorthandintro}}{}}
\DeclareBibliographyCategory{allowshorthand}
\AtEveryCitekey{%
\ifnumgreater{\value{citecounter}}{\SHthreshold}{%
\addtocategory{allowshorthand}{\thefield{entrykey}}%
}{%
}%
}
\textheight=250pt% just for the example
\begin{document}
\printshorthands[category=allowshorthand]
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}.
Some text \autocite{A01}. Some text \autocite{A01}. Some text \autocite{A01}.
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}.
\printbibliography
\end{document}