# Add period after author in biblatex with dashed entries

I need to add a period after the (last) author in my bibliography, right before the printed year. From Period after last author name in biblatex when terseinits = true I learned that I can do this with

\usepackage{xpatch}


But when the biblatex option dashed is set to true, and there are multiple entries within one year so that the letters a and b are added to separate them, the period is added after the year inside the parentheses instead of going after the dash.

\documentclass{article}
\usepackage[style = authoryear-comp, dashed = true]{biblatex}
\usepackage{xpatch}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{lennon1963,
AUTHOR = "John Lennon",
TITLE = "Does she love you? Yeah, yeah, yeah",
JOURNALTITLE = "Top of the Pops",
YEAR = "1963",
PAGES = "5--13"}
@article{lennon1967a,
AUTHOR = "John Lennon",
TITLE = "A day in whose life?",
JOURNALTITLE = "Top of the Pops",
YEAR = "1967",
PAGES = "12--24"}
@article{lennon1967b,
AUTHOR = "John Lennon",
TITLE = "Is love all you need?",
JOURNALTITLE = "Top of the Pops",
YEAR = "1967",
PAGES = "25--34"}
\end{filecontents}
\begin{document}
\nocite{*}
\printbibliography
\end{document}


You could check if the dash is printed, if so we do not add the period, otherwise we print it.

\xpretobibmacro{date+extrayear}
{\usebibmacro{bbx:dashcheck}
{}
{}{}


However, I think in this case a long solution is the most robust one. (You see how fickle the patching makes the macros.)

We replace some \setunit{\addspace} by \setunit{\addperiod\space} in the author, bbx:editor and bbx:translator macros:

\makeatletter
\renewbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\usebibmacro{bbx:savehash}%
\printnames{author}%
\iffieldundef{authortype}
\iffieldundef{authortype}
{}
{\usebibmacro{authorstrg}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\usebibmacro{date+extrayear}}

\newbibmacro*{bbx:editor}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames{editor}%
\usebibmacro{bbx:savehash}}%
\usebibmacro{#1}%
\clearname{editor}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\usebibmacro{date+extrayear}}

\newbibmacro*{bbx:translator}[1]{%
\ifboolexpr{
test \ifusetranslator
and
not test {\ifnameundef{translator}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames{translator}%
\usebibmacro{bbx:savehash}}%
\clearname{translator}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\usebibmacro{date+extrayear}}
\makeatother


MWE

\documentclass{article}
\usepackage[style = authoryear-comp, dashed = true]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{lennon1963,
AUTHOR = "John Lennon",
TITLE = "Does she love you? Yeah, yeah, yeah",
JOURNALTITLE = "Top of the Pops",
YEAR = "1963",
PAGES = "5--13"}
@article{lennon1967a,
AUTHOR = "John Lennon",
TITLE = "A day in whose life?",
JOURNALTITLE = "Top of the Pops",
YEAR = "1967",
PAGES = "12--24"}
@article{lennon1967b,
AUTHOR = "John Lennon",
TITLE = "Is love all you need?",
JOURNALTITLE = "Top of the Pops",
YEAR = "1967",
PAGES = "25--34"}
\end{filecontents*}
\makeatletter
\renewbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\usebibmacro{bbx:savehash}%
\printnames{author}%
\iffieldundef{authortype}
\iffieldundef{authortype}
{}
{\usebibmacro{authorstrg}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\usebibmacro{date+extrayear}}

\newbibmacro*{bbx:editor}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames{editor}%
\usebibmacro{bbx:savehash}}%
\usebibmacro{#1}%
\clearname{editor}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\usebibmacro{date+extrayear}}

\newbibmacro*{bbx:translator}[1]{%
\ifboolexpr{
test \ifusetranslator
and
not test {\ifnameundef{translator}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames{translator}%
\usebibmacro{bbx:savehash}}%
\clearname{translator}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\usebibmacro{date+extrayear}}
\makeatother
\begin{document}
\nocite{*}
\printbibliography
\end{document}


To include a period after the dash, go with

\renewcommand*{\bibnamedash}{%
\ifdimless{\leftmargin}{0.75em}

This just adds \addperiod after the different dashes.
• How easy would it be to implement an added period after the dash, i.e. -. (1967a).? It's not crucial, I guess, but the journal style sheet does indicate it ... :-/ Apr 27, 2014 at 14:46
• @Sverre I guess, one could just modify the \bibnamedash command to include the period. See edit. Apr 27, 2014 at 14:52
• That works, except that there is no space after the period, so it prints -.(1967a) rather than -. (1967a). I tried just adding \addspace and \space after \addperiod in your code, but nothing happened ... Apr 27, 2014 at 15:01
• @Sverre I do think there is a space between the period and the parentheses, my pdf reader even lets me select one. If you insist on more space, add a \space just before the last curly brace in the redefinition above. Apr 27, 2014 at 15:05
• You're right. It does add a space in this MWE, but it doesn't when I added your code to my style sheet .sty file. I'll try to find the culprit line in my .sty file that causes this. Apr 27, 2014 at 15:09