![如何限制 \nocite 到特定的参考段](https://linux22.com/image/386915/%E5%A6%82%E4%BD%95%E9%99%90%E5%88%B6%20%5Cnocite%20%E5%88%B0%E7%89%B9%E5%AE%9A%E7%9A%84%E5%8F%82%E8%80%83%E6%AE%B5.png)
我把我的参考书目按主题分成几个参考书目段在我的文章末尾。我想\nocite
在某些段环境中本地使用,但这似乎不可能\refsegment
,它仍然在全球范围内起作用。以下是一个例子:
\documentclass[10pt,a4paper,reqno]{amsart}
\usepackage[
backend=biber,
%heading = references,
citestyle=alphabetic,
bibstyle=alphabetic,
sorting=anyvt,
backref=true,
backrefstyle=none,
locallabelwidth=true
]{biblatex}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Book{Ahl,
author = {Ahlfors, L. V.},
title = {Complex Analysis, An Introduction to the Theory of Analytic Functions of One Complex Variable},
edition = {3},
publisher = {McGraw-Hill},
year = {1979},
keywords = {complex analysis}
}
@Book{BerGay,
author = {Berenstein, C. A. and Gay, R.},
title = {Complex Variables, An Introduction},
publisher = {Springer},
year = {1991},
keywords = {complex analysis}
}
@Book{AM,
author = {Atiyah, M. F. and MacDonald, I. G.},
title = {Introduction to Commutative Algebra},
publisher = {Addison-Wesley},
year = {1969},
keywords = {Algebra}
}
@Book{HoffKun,
author = {Hoffman, K. and Kunze, R.},
title = {Linear Algebra},
publisher = {Prentice-Hall},
edition = {2},
year = {1971},
keywords = {Algebra}
}
@Book{GrRem,
author = {Grauert, H. and Remmert, R.},
title = {Coherent Analytic Sheaves},
publisher = {Springer},
year = {1984}
}
@Book{Loday,
author = {Loday, J.-L.},
title = {Cyclic Homology},
publisher = {Springer},
year = {1998},
edition = {2}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{Ahl}, \cite{AM}, \cite{GrRem} are great books.
\begin{refsegment}
\nocite{*}
\printbibliography[keyword={complex analysis},title={References on Complex Analysis}]
\end{refsegment}
\begin{refsegment}
\printbibliography[keyword={Algebra},title={References on Algebra}]
\end{refsegment}
\printbibliography[notkeyword={complex analysis},notkeyword={Algebra},title={Other References}]
\end{document}
我知道\nocite
在本地行为是这样的\refsection
,但我不想将我的 .bib 文件拆分成各种不同的 .bib 文件,而且,biblatex 手册说这\refsegment
是我的情况的预期环境:-)\refsection
当我对不同的参考部分使用相同的 .bib 文件时,行为确实有点奇怪。
一个不太好的解决方法是将所有\nocite
参考段组合在一起后无\nocite
参考片段,但这破坏了主题的逻辑顺序。
有人知道这个问题的解决方案吗?
答案1
正如评论中提到的,refsegment
s 只会向条目添加标记(与keywords
或非常相似category
),它不会做更多的事情。默认情况下biblatex
甚至不会评估标记,因此一个条目中的\nocite{*}
/也会自然出现在所有其他段中。\nocite
refsegment
如果要将 限制\printbibliography
为一个refsegment
,则必须使用 选项segment
。这可能按以下方式工作。
\documentclass[10pt,a4paper,reqno]{amsart}
\usepackage[
backend=biber,
style=alphabetic,
sorting=anyvt,
backref=true,
backrefstyle=none,
locallabelwidth=true
]{biblatex}
\newrobustcmd{\mklocalfilter}[1]{%
\defbibfilter{#1}{%
segment=0
or
segment=\therefsegment
}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Ahl,
author = {Ahlfors, L. V.},
title = {Complex Analysis, An Introduction to the Theory of Analytic Functions of One Complex Variable},
edition = {3},
publisher = {McGraw-Hill},
year = {1979},
keywords = {complex analysis}
}
@book{BerGay,
author = {Berenstein, C. A. and Gay, R.},
title = {Complex Variables, An Introduction},
publisher = {Springer},
year = {1991},
keywords = {complex analysis}
}
@book{AM,
author = {Atiyah, M. F. and MacDonald, I. G.},
title = {Introduction to Commutative Algebra},
publisher = {Addison-Wesley},
year = {1969},
keywords = {algebra}
}
@book{HoffKun,
author = {Hoffman, K. and Kunze, R.},
title = {Linear Algebra},
publisher = {Prentice-Hall},
edition = {2},
year = {1971},
keywords = {algebra}
}
@book{GrRem,
author = {Grauert, H. and Remmert, R.},
title = {Coherent Analytic Sheaves},
publisher = {Springer},
year = {1984}
}
@book{Loday,
author = {Loday, J.-L.},
title = {Cyclic Homology},
publisher = {Springer},
year = {1998},
edition = {2}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{Ahl}, \cite{AM}, \cite{GrRem} are great books.
\begin{refsegment}
\mklocalfilter{nocitelocal}
\nocite{*}
\printbibliography[keyword={complex analysis},filter=nocitelocal,title={References on Complex Analysis}]
\end{refsegment}
% only cited entries, please
\printbibliography[keyword={algebra},segment=0,title={References on Algebra}]
% only cited entries, please
\printbibliography[notkeyword={complex analysis},notkeyword={algebra},segment=0,title={Other References}]
\end{document}
注意segment=0
适用于所有条目外部一个特定的refsegment
,并且 bibfilternocitelocal
直接在本地定义refsegment
以便使用变量\therefsegment
。
在此设置中,所有明确被\cite
'd 的条目均在 中被引用section=0
,但\nocite{*}
发生在 中segment=1
。因此,将参考书目限制为segment=0
给出了所有引用的条目,同时允许当前段也给出了本地所有条目的方法\nocite{*}
。
如果我们从不同的角度看待你的问题,我认为将其重新表述如下更为自然:我怎样才能\nocite
只输入特定关键词?不幸的是,是否可以使用 Biblatex/Biber 并在文档代码内根据关键字向参考书目添加条目?和此网站上的其他问题一样,没有通用的方法可以做到这一点。人们必须找到巧妙的解决方法。
对于您这种情况我们可以申请如何将参考书目分为“引用的作品”和“未引用的作品”?并提出
\documentclass[10pt,a4paper,reqno]{amsart}
\usepackage[
backend=biber,
%heading = references,
style=alphabetic,
sorting=anyvt,
backref=true,
backrefstyle=none,
locallabelwidth=true
]{biblatex}
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Ahl,
author = {Ahlfors, L. V.},
title = {Complex Analysis, An Introduction to the Theory of Analytic Functions of One Complex Variable},
edition = {3},
publisher = {McGraw-Hill},
year = {1979},
keywords = {complex analysis}
}
@book{BerGay,
author = {Berenstein, C. A. and Gay, R.},
title = {Complex Variables, An Introduction},
publisher = {Springer},
year = {1991},
keywords = {complex analysis}
}
@book{AM,
author = {Atiyah, M. F. and MacDonald, I. G.},
title = {Introduction to Commutative Algebra},
publisher = {Addison-Wesley},
year = {1969},
keywords = {algebra}
}
@book{HoffKun,
author = {Hoffman, K. and Kunze, R.},
title = {Linear Algebra},
publisher = {Prentice-Hall},
edition = {2},
year = {1971},
keywords = {algebra}
}
@book{GrRem,
author = {Grauert, H. and Remmert, R.},
title = {Coherent Analytic Sheaves},
publisher = {Springer},
year = {1984}
}
@book{Loday,
author = {Loday, J.-L.},
title = {Cyclic Homology},
publisher = {Springer},
year = {1998},
edition = {2}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
\cite{Ahl}, \cite{AM}, \cite{GrRem} are great books.
% all entries, cited and uncited
\printbibliography[keyword={complex analysis},title={References on Complex Analysis}]
% only cited entries, please
\printbibliography[keyword={algebra},category=cited,title={References on Algebra}]
% only cited entries, please
\printbibliography[notkeyword={complex analysis},notkeyword={algebra},category=cited,title={Other References}]
\end{document}