0

I am currently using biblatex (biber backend) with style=phys. In my bibliography, I have a few "highlighted publications" that I am setting in bold, using

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

which works like a charm. Now I would like the cite labels of the highlight category to show up in bold (and perhaps a different color), both in the bibliography as well as (even more important) in the main text. I have tried \AtEveryCite{\ifcategory{highlight}{\bfseries}{}} but that did not work at all.

Thank you very much for your help in advance!

EDIT: Please see below for my 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}
2
  • 1
    Welcome to TeX.SE! Please show us a short compilable TeX code (do not forget to add two or three bib entries too) , then we do not have to guess what you are doing ...
    – Mensch
    Oct 29, 2023 at 1:14
  • Hi @Mensch, thank you! I have added a MWE.
    – Faser
    Oct 29, 2023 at 16:50

1 Answer 1

1
+50

Use \AtEveryCitekey and not \AtEveryCite.

The latter is appended to whenever you issue a citation command, and the manual specifically says:

No bibliographic data is available at this point.

The former is appended at the beginning of processing for each cite key in a citation command, and the bibliographic data is available for it.


Complete example:

\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}

enter image description here

2
  • Hi Willie Wong, thank you, that works! But unfortanetly the numeric label in the bibliography is not made bold using that command, do you have any suggestion for fixing this? Thanks!
    – Faser
    Nov 3, 2023 at 17:11
  • Ah, sorry, I missed that part of your question. You need to also modify how the labelnumber field is printed in the bibliography. Let me add a complete example (should be done in about 5 minutes). Nov 5, 2023 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .