biblatex 中的粗体引用键

biblatex 中的粗体引用键

我目前正在使用 biblatex (biber 后端) style=phys。在我的参考书目中,我有一些“突出显示的出版物”,我使用粗体设置它们

\DeclareBibliographyCategory{highlight}
\AtEveryBibitem{\ifcategory{highlight}{\bfseries}{}}
\addtocategory{highlight}{myWork1,myWork2}

效果很好。现在我想让突出显示类别的引用标签以粗体显示(可能还有不同的颜色),无论是在参考书目中还是在正文中(更重要的是)。我试过了,但根本不起作用\AtEveryCite{\ifcategory{highlight}{\bfseries}{}}

非常感谢您的帮助!

编辑:请参阅下面的我的 MWE

\begin{filecontents}{\jobname.bib}
@article{test,
    author={A. Uthor},
    title = {A neat paper},
    journal = {Some random Journal},
    year = {2013}
}

@article{highlightEntry,
    author={Me},
    title = {Something great},
    journal = {Some Journal},
    year = {2023}
}
\end{filecontents}

\documentclass[a4paper,11pt]{article}

%%% packages %%%
\usepackage[colorlinks=true, citecolor=blue, linkcolor=blue, urlcolor=blue]{hyperref}
\usepackage[numbib,nottoc]{tocbibind} %%% bibsection style
\usepackage{mathtools}
\usepackage{amsfonts}

%%% bibliography stuff %%%

\usepackage[style=phys,biblabel=brackets,backend=biber,pageranges=false,defernumbers=true,maxnames=8]{biblatex}


\DeclareFieldFormat{titlecase}{#1}

\addbibresource{\jobname.bib}

\renewcommand*{\bibfont}{\normalfont\small}
\setlength{\bibitemsep}{0.1\baselineskip}

\DeclareBibliographyCategory{higlight}
\AtEveryBibitem{\ifcategory{higlight}{\bfseries}{}}

% highlighted papers
\addtocategory{higlight}{highlightEntry}

%%% bibliography style settings %%%
\let\OLDthebibliography\thebibliography
\renewcommand\thebibliography[1]{
  \OLDthebibliography{#1}
  \setlength{\parskip}{0pt}
  \setlength{\itemsep}{0pt}%{0.5ex plus 0.1ex}
}


\begin{document}

\section{My text}

test reference \cite{test} and then this second cite-key should be in bold \cite{highlightEntry}

\section{My bib}

\printbibliography[heading=none]

\end{document}

答案1

使用\AtEveryCitekey而不是\AtEveryCite

每当您发出引用命令时,都会附加后者,手册中具体说明了:

目前尚无可用的书目数据。

前者附加在引用命令中每个引用键处理的开始处,并且可获取书目数据。


完整示例:

\begin{filecontents}{\jobname.bib}
@article{test,
    author={A. Uthor},
    title = {A neat paper},
    journal = {Some random Journal},
    year = {2013}
}

@article{highlightEntry,
    author={Me},
    title = {Something great},
    journal = {Some Journal},
    year = {2023}
}
\end{filecontents}

\documentclass[a4paper,11pt]{article}

%%% packages %%%
\usepackage[colorlinks=true, citecolor=blue, linkcolor=blue, urlcolor=blue]{hyperref}
\usepackage[numbib,nottoc]{tocbibind} %%% bibsection style
\usepackage{mathtools}
\usepackage{amsfonts}

%%% bibliography stuff %%%

\usepackage[style=phys,biblabel=brackets,backend=biber,pageranges=false,defernumbers=true,maxnames=8]{biblatex}


\DeclareFieldFormat{titlecase}{#1}

\addbibresource{\jobname.bib}

\renewcommand*{\bibfont}{\normalfont\small}
\setlength{\bibitemsep}{0.1\baselineskip}

\DeclareBibliographyCategory{higlight}
\AtEveryBibitem{\ifcategory{higlight}{\bfseries}{}}
\AtEveryCitekey{\ifcategory{higlight}{\bfseries}{}} % Sets citation key, so prints bold when in category
\DeclareFieldFormat{labelnumber}{\ifcategory{higlight}{\bfseries}{}#1} % Make bibliography label also bold if in category

% highlighted papers
\addtocategory{higlight}{highlightEntry}

%%% bibliography style settings %%%
\let\OLDthebibliography\thebibliography
\renewcommand\thebibliography[1]{
  \OLDthebibliography{#1}
  \setlength{\parskip}{0pt}
  \setlength{\itemsep}{0pt}%{0.5ex plus 0.1ex}
}


\begin{document}

\section{My text}

test reference \cite{test} and then this second cite-key should be in bold \cite{highlightEntry}

\section{My bib}

\printbibliography[heading=none]

\end{document}

在此处输入图片描述

相关内容