11

I have a question that has been answered a few times, but does not work for me (and also not for another commenter in a previously asked question).

I want to remove the parenthesis around the yead in the bibliography with biblatex style authoryear, and ideally also add a comma and space before it. I have looked at the following questions:

biblatex: How to remove the parentheses around the year in authoryear style?

How to (properly) remove the parentheses around the year in authoryear style?

How to (properly) remove the parentheses around the year in authoryear style? (v2)

I use biber 2.10 and TexLive 2017/W32Tex.

This MWE should work according to the question v2 above, but does not work for me, i.e. the output is still Author, Anne (2001a). Alpha. The output I need is Author, Anne, 2001a. Alpha.

\documentclass{article}

\usepackage[style=authoryear,dashed=false]{biblatex}
\usepackage{xpatch,filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,author={Author, Anne},year={2001},title={Alpha}}
@misc{A02,author={Author, Anne},year={2001},title={Beta}}
\end{filecontents}
\addbibresource{\jobname.bib}

\xpatchbibmacro{date+extrayear}{%
  \printtext[parens]%
}{%
  \setunit*{\addperiod\space}%
  \printtext%
}{}{} 

\begin{document}
\nocite{*}
\printbibliography
\end{document} 

2 Answers2

11

The bibmacro date+extrayear is deprecated, and is replaced with date+extradate

\documentclass{article}

\usepackage[style=authoryear,dashed=false]{biblatex}
\usepackage{xpatch,filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,author={Author, Anne},year={2001},title={Alpha}}
@misc{A02,author={Author, Anne},year={2001},title={Beta}}
\end{filecontents}
\addbibresource{\jobname.bib}

\xpatchbibmacro{date+extradate}{%
  \printtext[parens]%
}{%
  \setunit*{\addcomma\space}%
  \printtext%
}{}{} 

\begin{document}
\nocite{*}
\printbibliography
\end{document} 

output of code

Alan Munn
  • 218,180
  • Oops, I was a tad too slow. (+1) (But the OP asks for a comma between the name and the year.) – gusbrs Apr 24 '18 at 02:15
  • 1
    @gusbrs I'll fix that. – Alan Munn Apr 24 '18 at 02:17
  • 2
    The macro in question was renamed in biblatex v3.8 (see https://github.com/plk/biblatex/wiki#release-notes-for-version-38 and in particular https://github.com/plk/biblatex/wiki/Name-Changes). These 'renaming sprees' should ideally be kept at a minimum and in hindsight changing the macro names might have been worse than living with the apparent slight inconsistency between macro name and field name. See also https://github.com/plk/biblatex/issues/700 – moewe Apr 24 '18 at 05:55
  • This solution appears not to work anymore. I've opened a question about it here. – Sverre May 31 '22 at 16:59
  • @Sverre It does work... if you read it more carefully. ;-) – gusbrs May 31 '22 at 17:07
  • @gusbrs You're right! And I've deleted my new question, as it didn't make sense anymore. – Sverre May 31 '22 at 17:13
6

Allow me to indulge in a bit of advertising for biblatex-ext. The ext-authoryear family has built-in support to change the format of the year. The ext-... styles are compatible with the standard styles and can be used as a drop-in replacement.

You just need to redefine the field format biblabeldate (a biblatex-ext feature) and the delimiter nameyeardelim (a standard biblatex feature) appropriately.

\documentclass{article}

\usepackage[style=ext-authoryear,dashed=false]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareFieldFormat{biblabeldate}{#1}
\DeclareDelimFormat[bib]{nameyeardelim}{\addcomma\space}

\begin{document}
\nocite{sigfridsson,knuth:ct:a,knuth:ct:b}
\printbibliography
\end{document}

enter image description here

moewe
  • 175,683