7

I am new here, so please bear with me. I would like to make the last name of the first author only in the bibliography boldface, i.e., in the MWE I want "Fox" in the bibliography only (not the citation) to be bold.

MWE:

\documentclass[a4paper,twoside,hidelinks]{article}
\usepackage[backend=biber,
        natbib=true,
        uniquename=false,
        uniquelist=false,
        firstinits=true,
        style=authoryear,
        sorting=nyt,
        maxcitenames=2,
        minbibnames=1,
        maxbibnames=100,
        block=none]{biblatex}

\bibliography{sample.bib}
\begin{document}
   Here is some sample text \parencite{Fox2011}.
\printbibliography
\end{document}

\RequirePackage{filecontents}
\begin{filecontents}{sample.bib}
   @ARTICLE{Fox2011,
   author = {Peter Fox and Richard Rabbit and Franc Bird},
      title = {Animals are the better humans},
      journal = {Horse and Hound},
      year = {2011},
      volume = {10},
      pages = {11--15}
}
\end{filecontents}
0
8

We redefine one bibmacro. The changes are actually very small: the insertion of a sprinking of \mkbibbold.

\renewbibmacro*{name:last-first}[4]{%
  \ifuseprefix
    {\usebibmacro{name:delim}{#3#1}%
     \usebibmacro{name:hook}{#3#1}%
     \ifblank{#3}{}{%
       \ifcapital
         {\mkbibbold{\mkbibnameprefix{\MakeCapital{#3}}\isdot}}
         {\mkbibbold{\mkbibnameprefix{#3}\isdot}}%
       \ifpunctmark{'}{}{\bibnamedelimc}}%
     \mkbibbold{\mkbibnamelast{#1}\isdot}%
     \ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%
     \ifblank{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{#2}\isdot}}
    {\usebibmacro{name:delim}{#1}%
     \usebibmacro{name:hook}{#1}%
     \mkbibbold{\mkbibnamelast{#1}\isdot}%
     \ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%
     \ifblank{#2#3}{}{\revsdnamepunct}%
     \ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{#2}\isdot}%
     \ifblank{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}}}

enter image description here

7
  • I'm getting an error message (using Texmaker pdflatex): ! Undefined control sequence. <argument> \revsdnamepunct \end{document} The control sequence at the end of the top line of your error message was never \def'ed. Tried deleting old compilation files, no change. – ashaels Mar 23 '14 at 11:09
  • That's very peculiar. What is the undeffed cs? \revsdnampunct is a standard biblatex feature; and this compiles fine for me inserted into the preamble of your example: it's not even part of the macro that I changed! – Paul Stanley Mar 23 '14 at 11:17
  • @ashaels Do you happen to run an outdated version of biblatex (the newest is 2.8a)? – moewe Mar 23 '14 at 14:40
  • +1 That is actually quite a smart redefinition. It will print all last names in "last, first" format bold, though. So if we switch to \DeclareNameAlias{sortname}{last-first}, all last names wil be bolded. – moewe Mar 23 '14 at 16:27
  • @moewe Yes. In such a case one would have to write a new macro (defined as here) and also new name format, exactly like the standard last-first/first-last, or whatever it's called, except with the new macro called in place of name:last-first. – Paul Stanley Mar 23 '14 at 17:24
7

I think this is best done with a dedicated name format.

The idea is to redefine the macro \mkbibnamefamily that prints the family name only for the first name, and then restore it.

By default authoryear uses family-given/given-family, so we define family-given/given-family-bf.

\DeclareNameFormat{family-given/given-family}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamefamily}[1]{\mkbibbold{##1}}%
     \ifgiveninits
       {\usebibmacro{name:family-given}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefix}
         {\namepartsuffix}}
       {\usebibmacro{name:family-given}
         {\namepartfamily}
         {\namepartgiven}
         {\namepartprefix}
         {\namepartsuffix}}%
     \ifboolexpe{%
       test {\ifdefvoid\namepartgiven}
       and
       test {\ifdefvoid\namepartprefix}}
       {}
       {\usebibmacro{name:revsdelim}}}
    {\renewcommand*{\mkbibnamefamily}[1]{##1}%
     \ifgiveninits
       {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefix}
         {\namepartsuffix}}
       {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiven}
         {\namepartprefix}
         {\namepartsuffix}}}%
  \usebibmacro{name:andothers}}

If you prefer all names in family-given

\DeclareNameFormat{family-given-fb}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamefamily}[1]{\mkbibbold{##1}}}
    {\renewcommand*{\mkbibnamefamily}[1]{##1}}%
  \ifgiveninits
    {\usebibmacro{name:family-given}
      {\namepartfamily}
      {\namepartgiveni}
      {\namepartprefix}
      {\namepartsuffix}}
    {\usebibmacro{name:family-given}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}}%
  \usebibmacro{name:andothers}}

Or given-family

\DeclareNameFormat{given-family-fb}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamefamily}[1]{\mkbibbold{##1}}}
    {\renewcommand*{\mkbibnamefamily}[1]{##1}}%
  \ifgiveninits
    {\usebibmacro{name:given-family}
      {\namepartfamily}
      {\namepartgiveni}
      {\namepartprefix}
      {\namepartsuffix}}
    {\usebibmacro{name:given-family}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}}%
  \usebibmacro{name:andothers}}

Then use one of the formats above via \DeclareNameAlias{sortname}{format}, for example

\DeclareNameAlias{sortname}{family-given-fb}

MWE

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

\DeclareNameAlias{sortname}{family-given-fb}
\DeclareNameFormat{family-given-fb}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamefamily}[1]{\mkbibbold{##1}}}
    {\renewcommand*{\mkbibnamefamily}[1]{##1}}%
  \ifgiveninits
    {\usebibmacro{name:family-given}
      {\namepartfamily}
      {\namepartgiveni}
      {\namepartprefix}
      {\namepartsuffix}}
    {\usebibmacro{name:family-given}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}}%
  \usebibmacro{name:andothers}}

\bibliography{biblatex-examples.bib}

\begin{document}
   Here is some sample text \parencite{baez/article}.

  \printbibliography
\end{document}

enter image description here

Edited for biblatex >= 3.3, the old version can be found in the edit history. Incidentally, it should not be necessary to restore the old definition of \mkbibnamefamily in future versions (i.e. > 3.11) since the names should be grouped https://github.com/plk/biblatex/pull/731.

1
  • This answer no longer works, due to biblatex changes. – Alan Munn Jun 10 '18 at 19:11

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.