3

I have the same question as asked in How to (properly) remove the parentheses around the year in authoryear style?. The accepted answer, however, no longer works (presumable due to some update to biblatex). What would the current solution be?

\documentclass{article}

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

\begin{filecontents}{\jobname.bib}
@misc{A01,author={Author, A.},year={2001},title={Alpha}}
@misc{A02,author={Author, A.},year={2001},title={Beta}}
\end{filecontents}
\addbibresource{\jobname.bib}
\xpatchbibmacro{date+extrayear}{%
  \printtext[parens]%
}{%
  \setunit{\addperiod\space}%
  \printtext%
}{}{}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

enter image description here

Sverre
  • 20,729
  • I can compile your file and the patch works fine. – Bernard Feb 03 '14 at 23:38
  • @Bernard Maybe different versions? I see the same problem as Sverre when I compile that code. – cfr Feb 04 '14 at 00:51
  • @cfr I use the last version: biblatex 2.8a (MiKTeX 2.9). – Bernard Feb 04 '14 at 07:15
  • To remove the parenthesis and add a period+space after the year, you can use \DeclareFieldFormat*{parens}{#1\addperiod\addspace}. However, I think it will format every fields in the bibliographic entry that are in parenthesis. – Luc M Dec 03 '14 at 16:31

1 Answers1

6

Replace

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

with

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

MWE:

\documentclass{article}

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

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

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

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

Output:

enter image description here

karlkoeller
  • 124,410
  • I actually tried this already - but this will remove the period placed after an author's name (before the year). – Sverre Feb 04 '14 at 11:59
  • @Sverre Are you saying that my MWE gives a different result to you? – karlkoeller Feb 04 '14 at 12:32
  • No, the period remains in the MWE because the input happens to have "A." with a period in the .bib file (I just copied the example from the original to preserve consistency - maybe I shouldn't have). If this were e.g. "Author, Anne", it would give "Author, Anne 2001a." without a period, rather than "Author, Anne. 2001a." – Sverre Feb 04 '14 at 12:37
  • @Sverre Note that there is no period between the author and the year in the normal behavior. – karlkoeller Feb 04 '14 at 12:42
  • True, but that's because the "normal behavior" puts the year in parentheses. If the bibliography style doesn't use parentheses, there should be a period. That's why the original solution had the \addperiod command there. – Sverre Feb 04 '14 at 12:44
  • @Sverre Now it should be like you wanted. – karlkoeller Feb 04 '14 at 12:57
  • Interesting. Could you say in short what \setunit*{} does that makes this work? – Sverre Feb 04 '14 at 13:02
  • 2
    @Sverre From the manual: The starred variant differs from the regular version in that it checks if the last \printtext, \printfield, \printlist, \printnames, or \bibstring command did actually print anything. If not, it does nothing. – karlkoeller Feb 04 '14 at 13:04
  • The MWE is not working for me with biber 2.10 and texlive 2017.44590 – gypaetus Feb 14 '18 at 15:45
  • With recent versions of biblatex you need to patch date+extradate since date+extrayear is deprecated. – Alan Munn Apr 24 '18 at 02:16