8

I have been using a snipet for making a specific authors name bold in the bibliography (see \newcommand below). It works very well, but it changes the style of the author from the default way (which I prefer, see image below). My problem is, that the command is rather complicated, and I don't really understand what happens there. I would really appreciate if someone could explain to me how to change the format back to the prefered and why that way, so I could actually understand the code (or is there a simpler way to achieve this bolding than the code below?).

Update

Added extra authors, notice that only the selected author (Strombom) is highlighted

MWEB

\documentclass{article}
\usepackage[defernumbers=true,sorting=none,backend=biber,maxnames=10]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}

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

\begin{filecontents}{\jobname.bib}
@article{Perunov,
author = {Perunov, Nikolay and Marsland, Robert A and England, Jeremy L},
doi = {10.1103/PhysRevX.6.021036},
keywords = {Biological Physics,Complex Systems,Statistical Physics,Subject Areas},
mendeley-groups = {dissertation},
title = {{Statistical Physics of Adaptation}},
url = {https://journals.aps.org/prx/pdf/10.1103/PhysRevX.6.021036}
}

@article{Strombom2011,
author = {Strombom, Daniel and Random, Author2 and Familyname, Givenname},
doi = {10.1016/j.jtbi.2011.05.019},
journal = {Journal of Theoretical Biology},
mendeley-groups = {dissertation},
month = {aug},
number = {1},
pages = {145--151},
title = {{Collective motion from local attraction}},
url = {http://linkinghub.elsevier.com/retrieve/pii/S002251931100261X},
volume = {283},
year = {2011},
keywords = "nourl"
}

@article{Gell-Mann1995,
author = {Gell-Mann, Murray and Random, Author2 and Familyname, Givenname},
doi = {10.1002/cplx.6130010105},
journal = {Complexity},
mendeley-groups = {dissertation},
month = {sep},
number = {1},
pages = {16--19},
publisher = {Wiley Subscription Services, Inc., A Wiley Company},
title = {{What is complexity?}},
url = {http://doi.wiley.com/10.1002/cplx.6130010105},
volume = {1},
year = {1995},
keywords = "nourl"
}
\end{filecontents}

\begin{document}

\nocite{*}
{
\makeauthorbold{Strombom}
\printbibliography[title={bad author},heading=subbibliography,keyword=nourl]
}


\printbibliography[title={good author},heading=subbibliography,notkeyword=nourl]
\end{document}

enter image description here

compile

lualatex mweb.tex && biber mweb  && lualatex mweb.tex

I compiled this with the above command.

$ lualatex --v
This is LuaTeX, Version beta-0.80.0 (TeX Live 2015) (rev 5238)
fbence
  • 1,585

1 Answers1

5

Based on the biblatex documentation, they way to handle this should be author annotations. If this should not only be applied for one sub-bibliography, move the \renewcommands to the preamble.

\documentclass{article}
\usepackage[defernumbers=true,sorting=none,backend=biber,maxnames=10]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Perunov,
author = {Perunov, Nikolay and Marsland, Robert A and England, Jeremy L},
doi = {10.1103/PhysRevX.6.021036},
keywords = {Biological Physics,Complex Systems,Statistical Physics,Subject Areas},
mendeley-groups = {dissertation},
title = {{Statistical Physics of Adaptation}},
url = {https://journals.aps.org/prx/pdf/10.1103/PhysRevX.6.021036}
}

@article{Strombom2011,
author = {Strombom, Daniel and Einstein, Albert},
doi = {10.1016/j.jtbi.2011.05.019},
journal = {Journal of Theoretical Biology},
mendeley-groups = {dissertation},
month = {aug},
number = {1},
pages = {145--151},
title = {{Collective motion from local attraction}},
url = {http://linkinghub.elsevier.com/retrieve/pii/S002251931100261X},
volume = {283},
year = {2011},
keywords = "nourl",
AUTHOR+an = {1=corresponding},
}

@article{Gell-Mann1995,
author = {Gell-Mann, Murray},
doi = {10.1002/cplx.6130010105},
journal = {Complexity},
mendeley-groups = {dissertation},
month = {sep},
number = {1},
pages = {16--19},
publisher = {Wiley Subscription Services, Inc., A Wiley Company},
title = {{What is complexity?}},
url = {http://doi.wiley.com/10.1002/cplx.6130010105},
volume = {1},
year = {1995},
keywords = "nourl"
}
\end{filecontents}

\begin{document}

\nocite{*}
{
\renewcommand*{\mkbibnamegiven}[1]{%
  \ifitemannotation{corresponding}
    {\textbf{#1}}
    {#1}}
\renewcommand*{\mkbibnamefamily}[1]{%
  \ifitemannotation{corresponding}
    {\textbf{#1}}
    {#1}}

\printbibliography[title={bad author},heading=subbibliography,keyword=nourl]
}


\printbibliography[title={good author},heading=subbibliography,notkeyword=nourl]
\end{document}

enter image description here

  • I get ! LaTeX Error: \mkbibnamegiven undefined. on your mwe. – fbence Jul 21 '17 at 22:36
  • 1
    @fbence There where a lot of changes between 2015 and 2017, for example first name is now given name, last name became family name. I cannot test this, but you can try to replace them or update to a current version of biblatex. – samcarter_is_at_topanswers.xyz Jul 21 '17 at 22:41
  • I'll deploy 2017 in a test environment tomorrow. On the other hand: I updated the mwe with extra authors, because from the looks of your mwe (which I can't test now :D), it seems that it would highlight all the authors of the given entry – fbence Jul 21 '17 at 22:43
  • @fbence I added an example for multiple authors – samcarter_is_at_topanswers.xyz Jul 21 '17 at 22:46