# Biblatex: How to automatically make in-text citations bold given a condition?

Related but probably not related enough: making citations bold latex and Color citation using biblatex : in-text + references (issue with postnote + bibliography)

I have been learning a thing or two about source maps. But I think this requires something else than source maps because I don't know how source maps can influence the in-text citation.

I want to do the following:

1. For every @inproceedings reference,
2. If the note field exists get the string,
3. If this string contains the substring www.youtube.com, then make the in-text citation bold, (e.g. [43] ). If this is not the case, then do nothing and let it display like normal (e.g. [43] ).

I know this is perhaps a relatively specific example, but this can be generalized relatively easy to other data types or other fields.

Justification: some of my references are multimedia systems. Reading papers are fun and all, but some researchers have amazing YouTube videos demonstrating their system, which is a really intuitive intro to start off with if a reader is interested in following a reference. I want to do this a bit subtle, and this is what I came up with.

A sourcemap is exactly the right tool here, you just need a way to communicate a match with your document. That is probably easiest done with a keyword. In the example the sourcemap sets the keyword important for matching entries. The \DeclareFieldFormat{labelnumberwidth}, \DeclareFieldFormat{boldimportant} and \renewbibmacro*{cite} then make sure that the citation label for an important entry becomes bold.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=numeric, backend=biber]{biblatex}
\usepackage{hyperref}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{appleby,
author    = {Humphrey Appleby},
title     = {On the Importance of the Civil Service},
booktitle = {Why We Matter},
date      = {1980},
note      = {The corresponding speech is available at \url{https://www.youtube.com/watch?v=IO9XlQrEt2Y}},
}
@book{hacker,
author    = {James Hacker},
title     = {The Government},
date      = {1981},
note      = {The corresponding speech is available at \url{https://www.youtube.com/watch?v=IO9XlQrEt2Y}},
}
\end{filecontents}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\pertype{inproceedings}
\step[fieldsource=keywords, match=\regexp{\A(.+)\Z}, replace=\regexp{\$1,}]
\step[fieldset=keywords, fieldvalue={important}]
}
}
}

\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{\ifkeyword{important}{\mkbibbold{#1}}{#1}}}
\DeclareFieldFormat{boldimportant}{\ifkeyword{important}{\mkbibbold{#1}}{#1}}
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\printtext[boldimportant]{%
\printfield{labelprefix}%
\printfield{labelnumber}%
\ifbool{bbx:subentry}
{\printfield{entrysetcount}}
{}}}}

\begin{document}
\cite{appleby,hacker}
\printbibliography
\end{document}


• I have to give it to you, you did it again. I'll put you in the acknowledgements of my thesis because you have been a huge help with this. Thanks! – Melvin Roest May 3 '18 at 15:03
• Great answer @moewe, how can I do it with alphabetic (or other) styles, instead of numeric? – Raziel Sep 28 at 9:50
• @Raziel The redefinition \renewbibmacro*{cite} needs to be based on the definition of cite in alphabetic.cbx (and not on the definition in numeric.cbx as in this answer). It is a bit awkward to give the necessary code here in the comments, so if you need help getting that to work, I suggest you ask a new question. – moewe Sep 28 at 10:01