# Bold name in bib when having a prefix in last name

I am using the template from here: https://www.overleaf.com/16456399bnxqhtkjwzft#/63153901/

I am trying to make my name bold in the publications list by setting in the .tex file:

\myname{de\bibnamedelima Klein}{Niek}


and in the .sty file

\newcommand{\myname}[2]{%
\def\@mylastname{#1}%
\def\@myfirstname{#2}%
}

\renewcommand*{\mkbibnamefamily}[1]{%
\ifboolexpr{ test {\ifdefstrequal{\namepartfamily}{\@mylastname}}
and
test {\ifdefstrequal{\namepartgiven}{\@myfirstname}}}
{\textbf{#1}}%
{#1}%
}

\renewcommand*{\mkbibnamegiven}[1]{%
\ifboolexpr{ test {\ifdefstrequal{\namepartfamily}{\@mylastname}}
and
test {\ifdefstrequal{\namepartgiven}{\@myfirstname}}}
{\textbf{#1}}%
{#1}%
}


and in the .bib file my name is written as:

de Klein, Niek


However, because I have two parts in my last name, it is not making it bold. When I change my name to Klein, Niek in the bib file and \myname{Klein}{Niek} in the tex file, or when I change my name to Klein, Niek de in the bib file and \myname{Klein}{Niek\bibnamedelima de} in the tex file it does correctly bold my name.

So the two part name does work if I put it as two first names, but not when I put it as two lasts names.

Compilable snippets:

cv.tex

\documentclass[a4paper,skipsamekey,11pt,british]{curve}
\usepackage{settings}
\myname{de\bibnamedelima Klein}{Niek}
\excludecomment{fullonly}
\begin{document}
\input{publications}
\end{document}


settings.sty

\RequirePackage[main=british]{babel}
\raggedright

\RequirePackage{fontawesome}

\RequirePackage{relsize}
\RequirePackage[dvipsnames,svgnames]{xcolor}
\RequirePackage{tikz}

\RequirePackage{comment}
\definecolor{SwishLineColour}{HTML}{88AC0B}
\definecolor{MarkerColour}{HTML}{B6073F}

% If you're not a researcher nor an academic, you probably don't need biblatex; delete this line.
\RequirePackage[backend=biber,bibstyle=apa,sorting=ydnt,uniquename=init,maxnames=7,defernumbers=true]{biblatex}
\DeclareLanguageMapping{british}{british-apa}

\RequirePackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,text=white,fill=MarkerColour!80!black,font=\sffamily\scriptsize\bfseries,inner sep=1pt,text height=1.35ex,minimum width=1.5em,text centered] (char) {#1};}}

\newcounter{bibitem}
\AtBeginBibliography{\setcounter{bibitem}{1}}
\AtEveryBibitem{\makebox[2.5em][l]{\circled{\thebibitem}\stepcounter{bibitem}}}
% \renewcommand{\bibfont}{\small}
\setlength{\bibitemsep}{1.5ex}
\setlength{\bibhang}{2.7em}
\NewBibliographyString{retrieved}
\NewBibliographyString{from}
\DefineBibliographyStrings{british}{
retrieved = {}
}

\rubricfont{\Large\bfseries\sffamily}
\setlength{\rubricspace}{2pt}
%\setlength{\rubricafterspace}{-9pt}
\setlength{\rubricafterspace}{-3pt}
\setlength{\subrubricspace}{3pt}
\setlength{\subrubricbeforespace}{4pt}
\begin{tikzpicture}[baseline]%\
\shade[left color=black!40!white, right color=white] rectangle (\@almosttextwidth,2.5pt);
\node[font={\@rubricfont},inner sep=0pt,text ragged,anchor=south west,text depth=.5ex,text height=1.5ex] at (1pt,2pt) {#1};
\end{tikzpicture}%
\vspace\rubricspace%
}

\subrubricfont{\large\bfseries\sffamily}
\subrubricalignment{l}

\newcommand{\makefield}[2]{\makebox[1.5em]{\color{MarkerColour!80!black}#1} #2\hspace{2em}}

\keyalignment{r}
\rubricalignment{l}
\renewcommand{\arraystretch}{1.25}
\urlstyle{tt}

\newcommand{\prefixmarker}[1]{\def\@prefixmarker{#1}}
\def\@prefixmarker{\relscale{.9}\faBookmark}

\prefix{%
\hspace*{-1ex}
\color{MarkerColour!80!black}\@prefixmarker%
\hspace*{1ex}%
}

\defbibfilter{booksandchapters}{%
( type=book or type=incollection )
}

\newcommand{\myname}[2]{%
\def\@mylastname{#1}%
\def\@myfirstname{#2}%
}

\renewcommand*{\mkbibnamefamily}[1]{%
\ifboolexpr{ test {\ifdefstrequal{\namepartfamily}{\@mylastname}}
and
test {\ifdefstrequal{\namepartgiven}{\@myfirstname}}}
{\textbf{#1}}%
{#1}%
}

\renewcommand*{\mkbibnamegiven}[1]{%
\ifboolexpr{ test {\ifdefstrequal{\namepartfamily}{\@mylastname}}
and
test {\ifdefstrequal{\namepartgiven}{\@myfirstname}}}
{\textbf{#1}}%
{#1}%
}



own-bib.bib

@article{example},
title={Some titel},
author={de Klein, Niek and Other, Authors},
journal={Journal},
volume={5},
pages={470},
year={2015},
publisher={Publisher}
}


You can use biblatex's field annotation facilities for the purpose. With them, you should indicate the annotation in the bib file with something like author+an = {1=mynamebold}, (1 refers to the first author of the list, mynamebold is the annotations name).

An then, you can redefine the name part macros to make the name bold conditionally on the presence of the annotation.

\documentclass[british]{article}

\usepackage{babel}
\usepackage[bibstyle=apa]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{example,
title={Some titel},
author={de Klein, Niek and Other, Authors},
author+an = {1=mynamebold},
journal={Journal},
volume={5},
pages={470},
year={2015},
publisher={Publisher}
}
\end{filecontents}

\renewcommand*{\mkbibnamegiven}[1]{%
\ifitemannotation{mynamebold}
{\textbf{#1}}
{#1}}

\renewcommand*{\mkbibnamefamily}[1]{%
\ifitemannotation{mynamebold}
{\textbf{#1}}
{#1}}

\renewcommand*{\mkbibnameprefix}[1]{%
\ifitemannotation{mynamebold}
{\textbf{#1}}
{#1}}

\begin{document}

\nocite{*}
\printbibliography

\end{document}


As far as biblatex is concerned, your family/last name is not de Klein, it is Klein when you input your name as author = {de Klein, Niek}. The de is treated as prefix/von part. Classical BibTeX knows four name parts (the term before the slash is biblatex's name see also Biblatex 3.3 name formatting, the term after the slash is BibTeX's name)

1. Family/last name, here Klein
2. Given/first name, here Niek
3. Prefix/von part, here de
4. Suffix/junior part, here <empty>

A name in the .bib file is parsed with certain rules to split it up into these four components. See How should I type author names in a bib file?

The name prefix is not treated as a rigid part of the family name because the traditions in some countries treat the name prefix differently. In German texts for example it might happen that prefixes like 'von', 'van', ... are treated and shown like an additional first name for sorting purposes (Beethoven, Ludwig van) or the prefix is displayed with the family name but ignored for sorting purposes (van Beethoven, Ludwig sorts under B). This is easier if the prefix is considered a part of its own.

This means that if you try \myname{Klein}{Niek} depending on the output format you could get

de Klein, Niek

Niek, Klein de

Niek de Klein

None of the above options are exactly what you want because the de is never in bold which looks absolutely weird in the third example and visually splits the de from your name in the other two examples. Additionally, someone called Niek Klein (without the de) would also be highlighted.

I suggest you find a different solution for bold names from Make specific author bold using biblatex. My favourite solution is presented in my answer

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{xpatch}

\makeatletter
\def\hlblx@bibfile@name{\jobname -boldnames.bib}
\newwrite\hlblx@bibfile
\immediate\openout\hlblx@bibfile=\hlblx@bibfile@name

\newcounter{hlblx@name}
\setcounter{hlblx@name}{0}

\newcommand*{\hlblx@writenametobib}[1]{%
\stepcounter{hlblx@name}%
\edef\hlblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\noexpand\hlblx@getmethehash{hlblx@name@\the\value{hlblx@name}}}}%
}%
\hlblx@tmp@nocite
\immediate\write\hlblx@bibfile{%
@misc{hlblx@name@\the\value{hlblx@name}, author = {\unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}

\AtEndDocument{%
\closeout\hlblx@bibfile}

\newcommand*{\hlbxl@boldhashes}{}
\DeclareNameFormat{hlblx@hashextract}{%
\xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
{}

\DeclareCiteCommand{\hlblx@getmethehash}
{}
{\printnames[hlblx@hashextract][1-999]{author}}
{}
{}

\newcommand*{\resetboldnames}{\def\hlbxl@boldhashes{}}

\newbibmacro*{name:bold}{%
\def\do##1{\iffieldequalstr{hash}{##1}{\bfseries\listbreak}{}}%
\dolistloop{\hlbxl@boldhashes}%
}
\makeatother

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{example,
title={Some titel},
author={de Klein, Niek and Other, Authors},
journal={Journal},
volume={5},
pages={470},
year={2015},
publisher={Publisher}
}
\end{filecontents}


It uses a bit of machinery to allow you to input your name exactly as you would type it in a .bib file. The answer is based on a version of Audrey's answer using hashes. Audrey's answer itself unfortunately does not take name prefixes into account for name comparisons, so both Niek de Klein and Niek Klein would be highlighted.