这是另一种情况,由于/biblatex
的变化,先前的代码不再执行所需的功能。biber
biblatex
运行代码时biblatex 条目中的逗号,它本身是来自使用 biblatex 放置 Jr. 和 Sr.,参考文献列表中的人名后面不再出现单词Jr.
和。我正在运行3.11 版和2.11 版。Sr.
biblatex
biber
\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\renewbibmacro*{name:last-first}[4]{%
\ifuseprefix
{\usebibmacro{name:delim}{#3#1}%
\usebibmacro{name:hook}{#3#1}%
\ifblank{#3}{}{%
\ifcapital
{\mkbibnameprefix{\MakeCapital{#3}}\isdot}
{\mkbibnameprefix{#3}\isdot}%
\ifpunctmark{'}{}{\bibnamedelimc}}%
\mkbibnamelast{#1}\isdot
\ifblank{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{#2}\isdot}%
\ifblank{#4}{}{\revsdnamepunct\bibnamedelimd\mkbibnameaffix{#4}\isdot}}
{\usebibmacro{name:delim}{#1}%
\usebibmacro{name:hook}{#1}%
\mkbibnamelast{#1}\isdot
\ifblank{#2#3}{}{\revsdnamepunct}%
\ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{#2}\isdot}%
\ifblank{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}%
\ifblank{#4}{}{\revsdnamepunct\bibnamedelimd\mkbibnameaffix{#4}\isdot}}}
\DeclareStyleSourcemap{
\maps[datatype = bibtex]{
\map{%% Make sure a field like [Adam John Smith] comes out as [Smith, Adam John]
\step[fieldsource = author,
match = \regexp{\A\[(.+)\s+([^\s]+)\]\Z},
replace = {[$2, $1]}]
}
\map{%% Abbreviate an entry such as Adam J[ohn] Smith to Smith, Adam J.
\step[fieldsource = author,
match = \regexp{(\w+)\[(.+?)\]},
replace ={$1.}]
}
\map{%% Abbreviate an entry such as [Adam John] Smith to Smith
\step[fieldsource = author,
notmatch = \regexp{\A\[(.+)\]\Z},
final]
\step[fieldsource = author,
match = \regexp{(\A|\,\s)\[(.+?)\]},
replace = {$1}]
}
}
}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@BOOK{lennon1970,
AUTHOR = "J[ohn] Lennon",
TITLE = "My life with the Beatles",
YEAR = "1970",
SORTNAME = "John Lennon"}
@BOOK{lennon1971,
AUTHOR = "[John Lennon]",
TITLE = "Moving on",
YEAR = "1971",
SORTNAME = "John Lennon"}
@BOOK{lennon1972,
AUTHOR = "[J. John Lennon]",
TITLE = "Moving further on",
YEAR = "1972",
SORTNAME = "John Lennon"}
@BOOK{lennon1973,
AUTHOR = "John Lennon",
TITLE = "Still moving on",
YEAR = "1973",
SORTNAME = "John Lennon"}
@BOOK{lennon1974,
AUTHOR = "[John] Lennon",
TITLE = "I'm out of here",
YEAR = "1974",
SORTNAME = "John Lennon"}
@BOOK{lennon1975,
AUTHOR = "Lennon, [John]",
TITLE = "I'm out of here",
YEAR = "1975",
SORTNAME = "John Lennon"}
@BOOK{beatles1970,
AUTHOR = "John W[inston] Lennon and J[ames] Paul McCartney",
TITLE = "Let it be",
YEAR = "1970"}
@BOOK{gauch2012,
AUTHOR = "Gauch, Jr., Hugh G.",
TITLE = "Scientific method in brief",
YEAR = "2012",
LOCATION = "Cambridge",
PUBLISHER = "Cambridge University Press"}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
答案1
这是由于 3.3 版本的名称格式发生了变化biblatex
。另请参阅Biblatex 3.3 名称格式。
虽然新名称格式的细节有所不同,但宏的一般结构(如name:family-given
(以前的name:last-first
))保持不变。因此,只要有一定经验,就可以从旧名称格式转换为新名称格式(如 Ulrike 对链接问题的回答和那里的链接中所述)。所以为了让我的生活更轻松,我只是name:family-given
从中复制biblatex.def
并与您的进行比较name:last-first
。与原始结构相比,唯一的结构变化是涉及/ 的name:family-given
行的位置。#4
\mkbibnamesuffix
请注意,我将“Jr.”/“Sr.”前面的逗号设为可自定义的\bibnamedelimsuffix
。
\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\newcommand*{\bibnamedelimsuffix}{\addcomma\bibnamedelimd}
\renewbibmacro*{name:family-given}[4]{%
\ifuseprefix
{\usebibmacro{name:delim}{#3#1}%
\usebibmacro{name:hook}{#3#1}%
\ifdefvoid{#3}{}{%
\ifcapital
{\mkbibnameprefix{\MakeCapital{#3}}\isdot}
{\mkbibnameprefix{#3}\isdot}%
\ifprefchar{}{\bibnamedelimc}}%
\mkbibnamefamily{#1}\isdot
\ifdefvoid{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{#2}\isdot}%
\ifdefvoid{#4}{}{\bibnamedelimsuffix\mkbibnamesuffix{#4}\isdot}}
{\usebibmacro{name:delim}{#1}%
\usebibmacro{name:hook}{#1}%
\mkbibnamefamily{#1}\isdot
\ifboolexpe{%
test {\ifdefvoid{#2}}
and
test {\ifdefvoid{#3}}}
{}
{\revsdnamepunct}%
\ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}\isdot}%
\ifdefvoid{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}%
\ifdefvoid{#4}{}{\bibnamedelimsuffix\mkbibnamesuffix{#4}\isdot}}}
\DeclareStyleSourcemap{
\maps[datatype = bibtex]{
\map{%% Make sure a field like [Adam John Smith] comes out as [Smith, Adam John]
\step[fieldsource = author,
match = \regexp{\A\[(.+)\s+([^\s]+)\]\Z},
replace = {[$2, $1]}]
}
\map{%% Abbreviate an entry such as Adam J[ohn] Smith to Smith, Adam J.
\step[fieldsource = author,
match = \regexp{(\w+)\[(.+?)\]},
replace ={$1.}]
}
\map{%% Abbreviate an entry such as [Adam John] Smith to Smith
\step[fieldsource = author,
notmatch = \regexp{\A\[(.+)\]\Z},
final]
\step[fieldsource = author,
match = \regexp{(\A|\,\s)\[(.+?)\]},
replace = {$1}]
}
}
}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@BOOK{lennon1970,
AUTHOR = "J[ohn] Lennon",
TITLE = "My life with the Beatles",
YEAR = "1970",
SORTNAME = "John Lennon"}
@BOOK{lennon1971,
AUTHOR = "[John Lennon]",
TITLE = "Moving on",
YEAR = "1971",
SORTNAME = "John Lennon"}
@BOOK{lennon1972,
AUTHOR = "[J. John Lennon]",
TITLE = "Moving further on",
YEAR = "1972",
SORTNAME = "John Lennon"}
@BOOK{lennon1973,
AUTHOR = "John Lennon",
TITLE = "Still moving on",
YEAR = "1973",
SORTNAME = "John Lennon"}
@BOOK{lennon1974,
AUTHOR = "[John] Lennon",
TITLE = "I'm out of here",
YEAR = "1974",
SORTNAME = "John Lennon"}
@BOOK{lennon1975,
AUTHOR = "Lennon, [John]",
TITLE = "I'm out of here",
YEAR = "1975",
SORTNAME = "John Lennon"}
@BOOK{beatles1970,
AUTHOR = "John W[inston] Lennon and J[ames] Paul McCartney",
TITLE = "Let it be",
YEAR = "1970"}
@BOOK{gauch2012,
AUTHOR = "Gauch, Jr., Hugh G.",
TITLE = "Scientific method in brief",
YEAR = "2012",
LOCATION = "Cambridge",
PUBLISHER = "Cambridge University Press"}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}