0

I need to boldface the year of publication in the bibliography. Using biblatex with the built-in author-year, I found the line

\DeclareFieldFormat{title}{\emph{#1}}

in the official documentation. So I figured that

\DeclareFieldFormat{year}{\mkbibbold{#1}}

should do the trick. However, using it as shown in the MWE below, this doesn't affect the way the bibliography is rendered (and neither does the title italicisation).

What am I doing wrong?

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

\begin{filecontents}{\jobname.bib}
@article{porter:1980,
  author = "Porter, Martin F.",
  journal = "Program",
  title = "An algorithm for suffix stripping",
  year = "1980"
}
\end{filecontents}
\addbibresource{\jobname.bib}

\DeclareFieldFormat{year}{\mkbibbold{#1}}

\begin{document}
As stated by \textcite{porter:1980}\dots
\printbibliography
\end{document}
3
  • Do you want the year to be boldface only in the bibliography, or also in citations?
    – Bernard
    Commented Aug 31, 2017 at 23:32
  • Actually, I need this for creating a stand-alone bibliography list without citations, using a series of \fullcite commands. However, your answer (you're going to write one, aren't you?) might be more valuable to future readers if you include both versions.
    – lenz
    Commented Aug 31, 2017 at 23:42
  • Yes, I'll look at it tomorrow. I don't think the citations years should be in boldface, that's the difficulty (at least for me…).
    – Bernard
    Commented Sep 1, 2017 at 0:42

1 Answer 1

1

What you are actually seeing here is not the year field, but labelyear, so you would have to do

\DeclareFieldFormat{labelyear}{\mkbibbold{#1}}

That, however, changes only the citations and does in most cases not affect the bibliography. In the bibliography the year is most often printed as part of a date via a \print...date... macro. Modifications to the field formats do not affect the \print...date... macros. Here, a very easy solution is

\DeclareFieldFormat{yearinbib}{\mkbibbold{\mkbibparens{#1}}}

\renewbibmacro*{date+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[yearinbib]{%
       \iffieldsequal{year}{labelyear}
         {\printlabeldateextra}%
         {\printfield{labelyear}%
          \printfield{extrayear}}}}}

With the upcoming version 3.8 of biblatex that code changes to

\renewbibmacro*{date+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[yearinbib]{%
       \iflabeldateisdate
         {\printdateextra}
         {\printlabeldateextra}}}}

MWE

\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareFieldFormat{labelyear}{\mkbibbold{#1}}

\DeclareFieldFormat{yearinbib}{\mkbibbold{\mkbibparens{#1}}}

\renewbibmacro*{date+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[yearinbib]{%
       \iffieldsequal{year}{labelyear}
         {\printlabeldateextra}%
         {\printfield{labelyear}%
          \printfield{extrayear}}}}}

\begin{document}
As stated by \textcite{sigfridsson}\dots
\printbibliography
\end{document}
3
  • Thank you, this works great, even without the labeldateparts package option (despite the docs saying so). I still don't quite understand why it didn't work for the title either, as it is not part of the label (I don't need it, I'm just curious).
    – lenz
    Commented Sep 1, 2017 at 8:18
  • @lenz It doesn't work for titles of @articles because they have a special type-specific format which can only be overwritten by \DeclareFieldFormat[article]{title}{\emph{#1}}. \DeclareFieldFormat{title}{\mkbibbold{#1}} will work for types without type-specific formats, e.g. @books. labeldateparts is automatically set to true by the authoryear style.
    – moewe
    Commented Sep 1, 2017 at 8:23
  • I see. Dang, there are just too many interdependencies in an elaborate bibliography/citation system... I'm glad I'm not the maintainer of biblatex, it's hard enough as a user.
    – lenz
    Commented Sep 1, 2017 at 8:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .