![Biblatex 类别之间的视觉区分](https://linux22.com/image/358488/Biblatex%20%E7%B1%BB%E5%88%AB%E4%B9%8B%E9%97%B4%E7%9A%84%E8%A7%86%E8%A7%89%E5%8C%BA%E5%88%86.png)
以下场景(网站上有很多关于此问题的问题):我有一个参考书目,其中包含我引用的项目和一些我没有引用的项目。因为我希望保留参考书目的排序顺序,所以我不希望像之前回答的那样分成不同的部分:如何将参考书目分为“引用的作品”和“未引用的作品”?(MWE 是从那里复制而来的)
我想要实现的是:\printbibliography
如果文档中没有引用该项目,我想打印整个条目文本并以灰色显示。这意味着如果条目不属于类别,则cited
项目的打印方式将有所不同。
注意:我在主文档中对参考书目使用了更复杂的设置,因此应避免更改每个字段以针对不同的类别打印不同的内容。
\documentclass{article}
\begin{filecontents*}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
\end{filecontents*}
\usepackage{biblatex}
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
Some text \autocite{A01,B02}.
\printbibliography
\end{document}
答案1
ifcategory
我认为,、DeclareFieldFormat
和的组合AtEveryBibitem
就能满足您的要求。
尝试这个:
\documentclass{article}
\begin{filecontents*}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
\end{filecontents*}
\usepackage{xcolor}
\usepackage{biblatex}
\pagestyle{empty}
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
\AtEveryBibitem{%
\ifcategory{cited}{}{\color{black!50}}}
\DeclareFieldFormat{labelnumberwidth}{%
\ifcategory{cited}{}{\color{black!50}}\mkbibbrackets{#1}}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
Some text \autocite{A01,B02}.
\printbibliography
\end{document}