2

I'm trying to implement the author highlighting provided here:

Make one author's name bold every time it shows up in the bibliography

The solution works fine until i activate the apa style for biblatex. Heres my code:

\documentclass{article}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage[
  babel,
  german=quotes
]{csquotes}

\usepackage[
  backend=biber,
  %style=apa, %<===========uncomment me!!
  sortcites=true,
  sorting=nyt,
  hyperref=true,
  backref=true,
  alldates=iso8601
]{biblatex}

\begin{filecontents}{\jobname.bib}
@article{zongker_chicken_2006,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {Zongker, Doug},
    urldate = {2013-04-05},
    date = {2006}
}

@article{zongker_chicken_2007,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {OhterZongker, Doug},
    urldate = {2013-04-05},
    date = {2007}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareLanguageMapping{ngerman}{ngerman-apa}

% https://tex.stackexchange.com/a/211821/48182
\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
  \edef\tempname{{#1}}%
  \ifnumequal{\value{listcount}}{1}
    {\ifnumequal{\value{liststop}}{1}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4\addcomma\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4}}{##1\addcomma\addspace ##4}}}
    {\ifnumless{\value{listcount}}{\value{liststop}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4}}{\addcomma\addspace ##1\addcomma\addspace ##4}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}%
    }%
}%
}
\makeauthorbold{Zongker}

\begin{document}
\fullcite{zongker_chicken_2006}


\fullcite{zongker_chicken_2007}
\end{document}

Heres the different output without style=apa

bold

with style=apa

not bold

Why doesn't my command overwrite the apa style ?

3

This post is now updated to work with biblatex >= 3.3 and biblatex-apa >= 6.8. The only change necessary is that the macro that was called name:apa:last-first in versions < 3.3 is now called name:apa:family-given. The patching has to be adapted to that name change. The old version can be found in the history of this answer.

The code you used does not work because biblatex-apa does not use the author format, but uses its own apaauthor.

I suggest you take Audrey's approach to Make specific author bold using biblatex with hashes as explained in Highlight an author in bibliography using biblatex allowing bibliography style to format it

The only thing we need to consider here is that the macro you need to patch is now called name:apa:family-given.

MWE (of course the hash 086a2ad072f9903168e35b73cd394263 is specific to the MWE, read about how to find out the hash in the answer linked to above)

\documentclass{article}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xpatch}
\usepackage[
  babel,
  german=quotes
]{csquotes}

\usepackage[
  backend=biber,
  style=apa,
  sorting=nyt,
  backref=true,
  alldates=iso
]{biblatex}

\newcommand*{\boldnames}{}

\newcommand*{\doboldhashes}[1]{%
  \iffieldequalstr{hash}{#1}
    {\bfseries\listbreak}
    {}}%

\newbibmacro*{name:bold}{%
  \forlistloop{\doboldhashes}{\boldnames}%
}

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

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

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{086a2ad072f9903168e35b73cd394263}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{zongker_chicken_2006,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {Zongker, Doug},
    urldate = {2013-04-05},
    date = {2006}
}

@article{zongker_chicken_2007,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {OhterZongker, Doug},
    urldate = {2013-04-05},
    date = {2007}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\fullcite{zongker_chicken_2006}

\fullcite{zongker_chicken_2007}
\end{document}

enter image description here

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.