1

I have a problem which is similar to this: Change citation delimiter between works of the same author (biblatex)

I want to change the delimiter between multiple citations by the same author depending on if there has been a postnote. If there is a post-note, citations should be separated with a semicolon, if there isn't one, with a comma. So what I have is:

Lennon 1971: 282; 1973; McCartney 1979; 1980

what I want is:

Lennon 1971: 282; 1973; McCartney 1979, 1980

MWE:

\documentclass{article}
\usepackage[style=authoryear, citestyle=authoryear-comp]{biblatex}
\DeclareFieldFormat{postnote}{#1}
\renewcommand{\postnotedelim}{\addcolon\addspace}
\renewcommand{\multicitedelim}{\addsemicolon\space}
\renewcommand{\compcitedelim}{\multicitedelim}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1971,
   AUTHOR = "John Lennon",
   TITLE = "My really long book on my life",
   YEAR = "1971",
   LOCATION = "Liverpool",
   PUBLISHER = "Penny Lane Press"}
@BOOK{lennon1973,
   AUTHOR = "John Lennon",
   TITLE = "Music -- why I make it",
   YEAR = "1973",
   LOCATION = "London",
   PUBLISHER = "Johnny Smith"}
@BOOK{mccartney1979,
   AUTHOR = "Paul McCartney",
   TITLE = "Penny Lane is still in my ears",
   YEAR = "1979",
   LOCATION = "New York",
   PUBLISHER = "Peter Alden"}
@BOOK{mccartney1980,
   AUTHOR = "Paul McCartney",
   TITLE = "Penny Lane is not anymore my ears",
   YEAR = "1980",
   LOCATION = "New York",
   PUBLISHER = "Peter Alden"}       
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cites[282]{lennon1971}{lennon1973}{mccartney1979}{mccartney1980}
\printbibliography
\end{document}
1

Set

\renewcommand{\multicitedelim}{\addsemicolon\space}
\renewcommand{\compcitedelim}{\addcomma\space}

And then define

\renewbibmacro*{postnote}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\postnotedelim}%
     \printfield{postnote}%
     \printunit{\multicitedelim}}}

So we effectively turn a \compcitedelim into a \multicitedelim after a postnote. The \printunit (in contrast to \setunit) makes sure that the punctuation is not overridden by another \setunit command following it.

MWE

\documentclass{article}
\usepackage[style=authoryear, citestyle=authoryear-comp]{biblatex}
\DeclareFieldFormat{postnote}{#1}
\renewcommand{\postnotedelim}{\addcolon\addspace}
\renewcommand{\multicitedelim}{\addsemicolon\space}
\renewcommand{\compcitedelim}{\addcomma\space}

\renewbibmacro*{postnote}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\postnotedelim}%
     \printfield{postnote}%
     \printunit{\multicitedelim}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1971,
   AUTHOR = "John Lennon",
   TITLE = "My really long book on my life",
   YEAR = "1971",
   LOCATION = "Liverpool",
   PUBLISHER = "Penny Lane Press"}
@BOOK{lennon1973,
   AUTHOR = "John Lennon",
   TITLE = "Music -- why I make it",
   YEAR = "1973",
   LOCATION = "London",
   PUBLISHER = "Johnny Smith"}
@BOOK{mccartney1979,
   AUTHOR = "Paul McCartney",
   TITLE = "Penny Lane is still in my ears",
   YEAR = "1979",
   LOCATION = "New York",
   PUBLISHER = "Peter Alden"}
@BOOK{mccartney1980,
   AUTHOR = "Paul McCartney",
   TITLE = "Penny Lane is not anymore my ears",
   YEAR = "1980",
   LOCATION = "New York",
   PUBLISHER = "Peter Alden"}       
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cites[282]{lennon1971}{lennon1973}{mccartney1979}{mccartney1980}
\printbibliography
\end{document}

example citation

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.