如何限制 \nocite 到特定的参考段

如何限制 \nocite 到特定的参考段

我把我的参考书目按主题分成几个参考书目在我的文章末尾。我想\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

正如评论中提到的,refsegments 只会向条目添加标记(与keywords或非常相似category),它不会做更多的事情。默认情况下biblatex甚至不会评估标记,因此一个条目中的\nocite{*}/也会自然出现在所有其他段中。\nociterefsegment

如果要将 限制\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}

MWE 显示三条引文和三份书目。第一份书目包含被引和未引条目,而其他两份书目仅包含被引条目。

注意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}

MWE 的屏幕截图显示了三个书目。第一个包含一个引用条目和一个未引用条目。其他两个书目仅包含引用条目。

相关内容