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 '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

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.
http://tex.stackexchange.com/questions/167190/bold-the-last-name-of-the-first-author-in-a-biblatex-bibliography
tex.stackexchange.com
crawl=CC-MAIN-2015-22
79524
application/http; msgtype=response
sha1:SW7N53UJUZLIUJXTYHQS3Q5TEMU4MSFX
<urn:uuid:8dc48dcd-46d0-46d5-b97d-3f4159876d33>
2015-05-26T10:17:14Z
104.16.13.13
sha1:5Y64NV4CRH64AS2ADAA27VCZ5W7ZJ5JJ
<urn:uuid:fb034181-ec5b-423f-8f79-edd6fa35f31b>
http://tex.stackexchange.com/questions/167190/bold-the-last-name-of-the-first-author-in-a-biblatex-bibliography
length
response
<urn:uuid:6a44d497-2ed4-4aab-b25b-5a324001e6cf>
robots: classic
hostname: ip-10-180-206-219.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-22
operator: CommonCrawl Admin
description: Wide crawl of the web for May 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf