I want to highlight a specific author in a bibliography and have working code based on the answer given here: https://tex.stackexchange.com/a/73246.
I am using biber and have chosen to use the name hash to indicate the author that should be highlighted.
I would like to store the hash in a variable; however, when I use the variable as input the code no longer works.
Here is the code example showing
- the working method - where the name hash is included explicitly
- the non-working method - where the hash is stored in a variable
I assume the solution isn't complicated, but I cannot work it out!
% -- bib file --------------------------------------------------------
\begin{filecontents}{\jobname.bib}
@InProceedings{identifier1,
Title = {Some Awesome Title},
Author = {Author, Some N. and Another Author},
Booktitle = {Some Book about the Future},
Year = {2042},
Pages = {1--42}
}
@InProceedings{identifier2,
Title = {Some So-So Title},
Author = {First Author and Author, Some N. and Third Author},
Booktitle = {An okay Booktitle},
Year = {2000},
Pages = {1--100}
}
\end{filecontents}
% --------------------------------------------------------------------
\documentclass{article}
\usepackage[
backend=biber,
style=authoryear-comp,
uniquename=false,
uniquelist=false,
dashed=false,
maxnames=99,
giveninits=true,
sorting=ynt,
sortcites=true,
hyperref=true,
backref=true,
backrefstyle=three,
]{biblatex}
\addbibresource{\jobname.bib}
% -- Define switches to turn bold on/off -----------------------------
\newif\ifBoldAuthor
\BoldAuthorfalse
\def\BoldAuthor{\BoldAuthortrue}
\def\NormalAuthor{\BoldAuthorfalse}
% --------------------------------------------------------------------
% -- Works -----------------------------------------------------------
\newbibmacro*{name:bold}[2]{
\ifBoldAuthor
\iffieldequalstr{hash}{78bd3199da266f516ab37d1ae346acd2}{\bfseries}{}%
\fi
}
% --------------------------------------------------------------------
% -- Does not work -------------------------------------------
%% Hash of author name to make bold
%\def\authorhash{78bd3199da266f516ab37d1ae346acd2}
%
%\newbibmacro*{name:bold}[2]{
% \ifBoldAuthor
% \iffieldequalstr{hash}{\authorhash}{\bfseries}{}%
% \fi
%}
% --------------------------------------------------------------------
% --------------------------------------------------------------------
\usepackage{xpatch}
\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}
\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}
% --------------------------------------------------------------------
\begin{document}
\nocite{*}
\BoldAuthor{}
\printbibliography
\NormalAuthor{}
\printbibliography
\end{document}

