在破折号作者后添加句号,但在破折号编辑后添加逗号(biblatex)

在破折号作者后添加句号,但在破折号编辑后添加逗号(biblatex)

首先,我删除参考书目中年份周围的括号,并在条目名称后添加一个句点:

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

(从这个答案)。

然后我在破折号后面添加一个句点,表示虚线条目:

\renewcommand*\bibnamedash{\rule[0.48ex]{3em}{0.14ex}\addperiod\space}

当虚线条目是作者时,这看起来不错(参见下面 MWE 中的 McCartney),但对于虚线编辑者来说,这看起来是错误的。而不是

------。1966 年编辑。更多我喜欢的歌曲

它应该是

------,1966 年编辑。更多我喜欢的歌曲

实际上,破折号只应替换重复的名称,而不会改变其他内容。我该怎么做?

\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{lennon1965,
    EDITOR = "John Lennon",
    TITLE = "Old songs I like",
    YEAR = "1965"}
@book{lennon1966,
    EDITOR = "John Lennon",
    TITLE = "More old songs I like",
    YEAR = "1966"}
@book{mccartney1965,
    AUTHOR = "Paul McCartney",
    TITLE = "This is what I did yesterday",
    YEAR = "1965"}
@book{mccartney1966,
    AUTHOR = "Paul McCartney",
    TITLE = "My troubles don't seem so far away",
    YEAR = "1966"}

\end{filecontents}
\addbibresource{\jobname.bib}

\usepackage{xpatch}
    \xpatchbibmacro{date+extrayear}{\printtext[parens]}{\setunit*{\addperiod\space}\printtext}{}{} % remove parenthesis around year in bibliography
\renewcommand*\bibnamedash{\rule[0.48ex]{3em}{0.14ex}\addperiod\space} % use a 3em dash with period after it for dashed author names

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

在此处输入图片描述

答案1

利用的biblatex标点符号跟踪器。

\renewcommand*\bibnamedash{%
  \printtext{%
    \rule[0.48ex]{3em}{0.14ex}}%
  \setunit{\addcomma\space}}

这样,我们就可以打印出名称破折号,然后使用标点符号跟踪器来帮我们整理。

\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{lennon1965,
    EDITOR = "John Lennon",
    TITLE = "Old songs I like",
    YEAR = "1965"}
@book{lennon1966,
    EDITOR = "John Lennon",
    TITLE = "More old songs I like",
    YEAR = "1966"}
@book{mccartney1965,
    AUTHOR = "Paul McCartney",
    TITLE = "This is what I did yesterday",
    YEAR = "1965"}
@book{mccartney1966,
    AUTHOR = "Paul McCartney",
    TITLE = "My troubles don't seem so far away",
    YEAR = "1966"}

\end{filecontents}
\addbibresource{\jobname.bib}

\usepackage{xpatch}
  \xpatchbibmacro{date+extrayear}{\printtext[parens]}{\setunit*{\addperiod\space}\printtext}{}{}
\renewcommand*\bibnamedash{\printtext{\rule[0.48ex]{3em}{0.14ex}}\setunit{\addcomma\space}}

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

我们得到

正确虚线参考书目

相关内容