Biblatex:带有后记的同一作者作品之间的引用分隔符

Biblatex:带有后记的同一作者作品之间的引用分隔符

我有一个与此类似的问题:更改同一作者的作品之间的引用分隔符(biblatex)

我想根据是否有后记来更改同一作者的多个引文之间的分隔符。如果有后记,则应使用分号分隔引文,如果没有,则使用逗号分隔。所以我有:

列侬 1971 年:282;1973 年;麦卡特尼 1979 年;1980 年

我想要的是:

列侬 1971 年:282;1973 年;麦卡特尼 1979 年、1980 年

梅威瑟:

\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

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

然后定义

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

因此,我们实际上将后记中\compcitedelim的变成了。 (与 相对)确保标点符号不会被其后的其他命令覆盖。\multicitedelim\printunit\setunit\setunit

平均能量损失

\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}

示例引文

答案2

一个更简单的解决方案,避免弄乱 postnote 宏,并且具有独立于 \multicitedelim 定义工作的优势,如下所示:

\renewcommand{\compcitedelim}{\iffieldundef{postnote}{\addcomma\space}{\addsemicolon\space}}

相关内容