I want to be able to define a list of authors in a command and highlight them in the bibliography or citations. I am using biblatex with my latex document (I have not been able to update my OS lately and I am using Package: biblatex 2013/11/25 v2.8a programmable bibliographies (PK/JW/AB)).
So far I have been able to create a new macro that is called each time the names of the authors are printed. However, when I compare the author last name and first name with the values that I defined using \newcommand, I always get the evaluation to false in the if statement. Here is what I got so far (inspired by a combination of [1], [2] and [3]) :
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{boldref,
AUTHOR = {InBold, to Put and Author, Non bold and Highlight, Shine and Ano, therOne},
TITLE = {The title},
BOOKTITLE = {The conference},
PAGES = {65--78},
YEAR = 2014}
\end{filecontents}
\usepackage{xpatch}
\usepackage[normalem]{ulem}
\usepackage{color}
\usepackage[backend=biber,bibencoding=utf8,style=numeric-comp,maxbibnames=99,firstinits=true]{biblatex}
\addbibresource{\jobname.bib}
\newcommand{\authorgivenname}{t. P.}
\newcommand{\authorfamilyname}{InBold}
\newcommand{\authorbibname}{\authorfamilyname, \authorgivenname}
\newbibmacro*{name:emph}[2]{%
First arugment: #1 =? \authorfamilyname \\
Second argument: #2 =? \authorgivenname \\
\ifstrequal{#2}{\authorgivenname}
{
\textcolor{green}{Evaluated to true: #1, #2} \\
}
{
\textcolor{red}{Evaluated to false: #1, #2} \\
}
}
\xpretobibmacro{name:last}{\begingroup\usebibmacro{name:emph}{#1}{#2}}{}{}
\xpretobibmacro{name:first-last}{\begingroup\usebibmacro{name:emph}{#1}{#2}}{}{}
\xpretobibmacro{name:last-first}{\begingroup\usebibmacro{name:emph}{#1}{#2}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}
\xapptobibmacro{name:last}{\endgroup}{}{}
\xapptobibmacro{name:first-last}{\endgroup}{}{}
\xapptobibmacro{name:last-first}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}
\begin{document}
\nocite{*}
\noindent\fullcite{boldref}
\end{document}
If I get this code to work, the idea is that I will change \textcolor{green}{Evaluated to true: #1, #2} to \bfseries and the author name will be in bold font. I suspect that this has to do with when each element is expanded. Am I right? How can I fix it? Moreover, how can I extend it to compare with a list of elements rather than just one author?
I also noted that the variables #1 and #2 are already processed by some other macro when the macro name:emph is called and give the abbreviated name (if it is requested in the configuration of biblatex). This means that I would have to declare different authors names depending on the configuration of firstinits option in biblatex.
Thank you very much.
P.S.: I have read other options that add elements to the bibliography entries ([1] or [4]) but I do not want that as I automatically generate my bibliography files (.bib) with programs that do not support adding fields. I have also tried to build on top of [5] but I cannot even get to compile that example.
given-familyinstead offirst-last) do no work for me. – apalomer Apr 14 '18 at 15:35\ifdefstring{\authorgivenname}{#2}was the solution!! Moreover, I think this answer is a very good answer as it gives a lot of options and references to other good answers. I keep this for when I update the biblatex (as I assume it will stop working). – apalomer Apr 14 '18 at 16:13