2

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}
\xpretobibmacro{date+extrayear}{\setunit{\addperiod\space}}{}{}

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}
\xpretobibmacro{date+extrayear}{\setunit{\addperiod\space}}{}{}
\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}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

enter image description here

3

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}
    {}
    {\setunit{\addperiod\space}}}
  {}{}

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}
          {\setunit{\addperiod\space}}
          {\setunit{\addcomma\space}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
        \setunit{\addperiod\addspace}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\adddperiod\space}}%
  \usebibmacro{date+extrayear}}


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


\newbibmacro*{bbx:translator}[1]{%
  \ifboolexpr{
    test \ifusetranslator
    and
    not test {\ifnameundef{translator}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\printnames{translator}%
        \setunit{\addcomma\space}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{translator+othersstrg}%
     \clearname{translator}%
     \setunit{\addperiod\space}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \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*}
\addbibresource{\jobname.bib}
\makeatletter
\renewbibmacro*{author}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\usebibmacro{bbx:savehash}%
        \printnames{author}%
        \iffieldundef{authortype}
          {\setunit{\addperiod\space}}
          {\setunit{\addcomma\space}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
        \setunit{\addperiod\addspace}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\adddperiod\space}}%
  \usebibmacro{date+extrayear}}


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


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

enter image description here


To include a period after the dash, go with

\renewcommand*{\bibnamedash}{%
  \ifdimless{\leftmargin}{0.75em}
    {\mbox{\textemdash\addperiod\space}}
    {\makebox[\leftmargin][l]{%
       \ifdimless{\leftmargin}{1.25em}
         {\textendash\addperiod}
         {\textemdash\addperiod}}}}

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 ... :-/ – Sverre Apr 27 '14 at 14:46
  • @Sverre I guess, one could just modify the \bibnamedash command to include the period. See edit. – moewe Apr 27 '14 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 ... – Sverre Apr 27 '14 at 15:01
  • 1
    @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. – moewe Apr 27 '14 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. – Sverre Apr 27 '14 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.