2

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}
\addbibresource{own-bib.bib}
\myname{de\bibnamedelima Klein}{Niek}
\excludecomment{fullonly}
\begin{document}
\input{publications}
\end{document}

settings.sty

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

\RequirePackage{fontawesome}



\RequirePackage[a4paper,nohead,nofoot,hmargin=2.25cm,vmargin=2cm]{geometry}
\RequirePackage{relsize}
\RequirePackage[dvipsnames,svgnames]{xcolor}
\RequirePackage{tikz}
\usetikzlibrary{shapes,shadows}

\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}{
  from = {\textcolor{MarkerColour!80!black}{\faLink}},
  retrieved = {}
}

\headerscale{1}
%\setlength{\headerspace}{6pt}
\rubricfont{\Large\bfseries\sffamily}
\setlength{\rubricspace}{2pt}
%\setlength{\rubricafterspace}{-9pt}
\setlength{\rubricafterspace}{-3pt}
\setlength{\subrubricspace}{3pt}
\setlength{\subrubricbeforespace}{4pt}
\def\@@rubrichead#1{%
  \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}%
}

\newcommand{\makerubrichead}[1]{\vskip\baselineskip\@@rubrichead{#1}}

\defbibheading{subbibliography}{\vskip\subrubricbeforespace{\@subrubricfont\hspace{3pt}#1}\par}

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

\RequirePackage[colorlinks=true,allcolors=black,breaklinks=true]{hyperref}

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

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}

\addbibresource{\jobname.bib}

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

enter image description here

4

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}

\addbibresource{\hlblx@bibfile@name}

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

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

\newcommand*{\addboldnames}{\forcsvlist\hlblx@writenametobib}
\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}{}{}

\addboldnames{Niek de Klein}

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

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson,example}
\printbibliography
\end{document}

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.