
我有一些特别重要的参考书目条目,例如下面例子中的 Genius 和 Vader 的条目。从这个例子中我们可以看出,“Lasers and Death Stars”显然是一部重要的作品,因此我需要在正文和参考书目中强调它!我给引文涂上了接近 Lord Vader 的光剑的颜色,但我担心如果我不在正文中给条目涂上颜色,他可能会压碎我的喉咙。
在下面的例子中,我怎样才能为 Genius02 引文着色而不为 Doe01 着色?
我希望在我感受到西斯尊主的愤怒之前有人能帮助我。
\RequirePackage{filecontents}
\begin{filecontents}{\min.bib}
@article{Doe01,
title={Some Title},
author={Doe, John and Bar, Foo},
journal={A Journal},
year={2001}
}
@article{Genius02,
title={Lasers and Death Stars},
author={Genius, Evil and Vader, Darth},
journal={Journal of World Domination},
year={2002}
}
\end{filecontents}
\documentclass[10pt]{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{\min.bib}
\DeclareBibliographyCategory{important}
\usepackage[dvipsnames]{xcolor}
%Emphasis in bibliography. Solution by "Jon", link above
\AtEveryBibitem{%
\ifcategory{important}%
{\bfseries\color{red}}%
{}%
}%How can this be inherited by the cite commands?
% Add books to 'important' category in preamble
\addtocategory{important}{%
Genius02,
}
\begin{document}
\cite{Doe01,Genius02}. I need the Genius02 citation (Not just the bibliography entry) to be emphasized!
\printbibliography
\end{document}
答案1
\AtEveryBibitem
在一个块中复制代码就足够了\AtEveryCitekey
。
只需添加
\AtEveryCitekey{%
\ifcategory{important}%
{\bfseries\color{red}}%
{}}
答案2
Category important not declared
您看到了由您的代码引起的 错误消息吗?
只需添加\DeclareBibliographyCategory{important}
到您的代码中。
然后还有一些小错误,例如你必须将新书/文章的关键字添加到\addtocategory
。最后我把粗体字改成了斜体字(为了看得更清楚,我把它涂成了红色)。
请参阅以下 MWE(已更改,标有<=============
):
\RequirePackage{filecontents} % <=================================
\begin{filecontents}{\jobname.bib}
@article{Doe01,
title = {Some Title},
author = {Doe, John and Bar, Foo},
journal = {A Journal},
year = {2001},
}
@article{Genius02,
title = {Lasers and Death Stars},
author = {Genius, Evil and Vader, Darth},
journal = {Journal of World Domination},
year = {2002},
}
\end{filecontents}
\documentclass[10pt]{article}
\usepackage[%
backend=biber
]{biblatex}
\addbibresource{\jobname.bib} %<========================================
\DeclareBibliographyCategory{important} % <=============================
\usepackage[dvipsnames]{xcolor}
%Emphasis in bibliography. Solution by "Jon", link above
\AtEveryBibitem{%
\ifcategory{important}%
{\itshape\color{Red}}%\bfseries % <============================
{}%
}%How can this be inherited by the cite commands?
% Add books to 'important' category in preamble
\addtocategory{important}{%
Genius02, % <=========================================================
}
\begin{document}
\cite{Doe01,Genius02}.
\printbibliography
\end{document}
结果: