Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

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

share|improve this answer
    
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 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 at 11:17
    
@ashaels Do you happen to run an outdated version of biblatex (the newest is 2.8a)? –  moewe Mar 23 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 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 at 17:24

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

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

By default authoryear uses last-first/first-last, so we define last-first/first-last-bf.

\DeclareNameFormat{last-first/first-last-bf}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamelast}[1]{\mkbibbold{##1}}%
     \iffirstinits
       {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
       {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}%
     \ifblank{#3#5}
       {}
       {\usebibmacro{name:revsdelim}}}
    {\renewcommand*{\mkbibnamelast}[1]{##1}%
     \iffirstinits
       {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
       {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}%
  \usebibmacro{name:andothers}}

If you prefer all names in last-first

\DeclareNameFormat{last-first-fb}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamelast}[1]{\mkbibbold{##1}}}
    {\renewcommand*{\mkbibnamelast}[1]{##1}}%
  \iffirstinits
    {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
    {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}
  \usebibmacro{name:andothers}}

Or first-last

\DeclareNameFormat{first-last-fb}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamelast}[1]{\mkbibbold{##1}}}
    {\renewcommand*{\mkbibnamelast}[1]{##1}}%
  \iffirstinits
    {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
    {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}%
  \usebibmacro{name:andothers}}

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

\DeclareNameAlias{sortname}{last-first-fb}

MWE

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

\DeclareNameAlias{sortname}{last-first-fb}
\DeclareNameFormat{last-first-fb}{%
  \ifnumequal{\value{listcount}}{1}
    {\renewcommand*{\mkbibnamelast}[1]{\mkbibbold{##1}}}
    {\renewcommand*{\mkbibnamelast}[1]{##1}}%
  \iffirstinits
    {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
    {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}
  \usebibmacro{name:andothers}}

\bibliography{biblatex-examples.bib}

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

  \printbibliography
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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