0

I've read the previous questions on this topic: 1, 2 but I am wondering whether there is an easier solution that does not require xpatch but (maybe) instead uses annotation functionality of recent bibtex/biber (for example \AtEveryBibitem I think) combined with the author hash provided by biber?

moewe
  • 175,683
  • 1
    https://tex.stackexchange.com/a/304968/35864 shows how to use the annotation feature. https://tex.stackexchange.com/q/274436/35864 is an approach with hashes, but there I used xpatch. One could directly redefine all involved macros to avoid xpatch, but I don't see the benefit. – moewe May 07 '17 at 07:10
  • 1
    Please explain your use case for not wishing to use xpatch. – Mico May 07 '17 at 07:16
  • I use the solution in https://tex.stackexchange.com/questions/33330/make-one-authors-name-bold-every-time-it-shows-up-in-the-bibliography/47655 . Look for the Answer of Lawrence Crosby – bene May 07 '17 at 07:40

1 Answers1

3

Currently I don't see a way around hacking into the biblatex macros.

\documentclass{article}
\usepackage{biblatex,xparse}
\addbibresource{biblatex-examples.bib}

%%%

\ExplSyntaxOn

\clist_new:N \bib_author_bold_clist

\NewDocumentCommand \makeauthorbold { m }
{
  \clist_put_right:Nn \bib_author_bold_clist { #1 }
}

\cs_generate_variant:Nn \clist_if_in:NnT { NxT }

\NewDocumentCommand \authorbold { m }
{
  \clist_if_in:NxT \bib_author_bold_clist { #1 } { \bfseries }
}

\ExplSyntaxOff

\renewbibmacro*{name:given-family}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \begingroup
  \authorbold{#1}%
  \ifdefvoid{#2}{}{\mkbibnamegiven{#2}\isdot\bibnamedelimd}%
  \ifdefvoid{#3}{}{%
    \mkbibnameprefix{#3}\isdot
    \ifprefchar
      {}
      {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
  \mkbibnamefamily{#1}\isdot
  \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}%
  \endgroup}

%%%

\makeauthorbold{Kastenholz, Hünenberger}

\begin{document}

\nocite{kastenholz}

\printbibliography

\end{document}

enter image description here

Henri Menke
  • 109,596
  • Dear all, thanks a lot for our quick and helpful replies. I am always amazed by the community here on stackexchange.

    I've used the solution from https://tex.stackexchange.com/a/274571/132424 now - works very nicely. @Mico: The motivation to ask for a solution that works without xpatch is simply because I like concise solutions that use the latest features offered by the packages.

    – andyknownasabu May 07 '17 at 08:30
  • Note that this answer is similar to https://tex.stackexchange.com/a/73246/35864, except that here LaTeX3 was used and the macro was modified directly instead of via xpatch. The drawback (or advantage) is that this solution here only compares last names, but it could be extended to first names as well (but one would need to be careful about \bibnamedelim...s then). – moewe May 07 '17 at 11:50
  • @andyknownasabu Ah, OK. xpatch is only used to avoid having to copy lots of macro definitions, so I don't think it is problematic in this case at all - and it actually makes things more concise. The only 'new' features are the annotation feature, which helps only for a manual solution (probably not what you want), and the hash as explained in the answer you use now. (Though I have to admit that while I prefer the hash solution it is not superior to a well-written solution that compares name parts. But writing such a string comparison solution is beyond my skill - the hash not so much.) – moewe May 07 '17 at 11:54