按照@moewe 在问题中的建议仅为编辑器启用 biblatex 中的“firstinits”和在 biblatex 中将编辑姓名后跟 (Ed./Eds.) 和标题前的逗号,我有您在下面看到的代码。这里的问题是,In
当集合没有编辑器时,它会在后面打印一个多余的句点,如Brekke
条目中所示。
\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books
%% Abbreviate first names of editors
\DeclareNameAlias{byeditor}{first-last-inits}
\DeclareNameFormat{first-last-inits}{%
\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}%
\usebibmacro{name:andothers}}
%%
%% Move names of editors before the book title, and add "(Eds.)"
\usepackage{xpatch}
\DeclareNameAlias{editorin}{first-last-inits}
\newbibmacro*{byeditor:in}{%
\ifnameundef{editor}
{}
{\printnames[editorin]{editor}%
\addspace\bibsentence%
\mkbibparens{\usebibmacro{editorstrg}}%
\clearname{editor}%
\printunit{\addcomma\space}}}
\xpatchbibdriver{incollection}
{\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{byeditor:in}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor}}
{}{}
%%
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INCOLLECTION{brekke1881,
AUTHOR = "K. Brekke",
BOOKTITLE = "Indbydelsesskrift til den offentlige examen i juni og juli 1881 ved Aars og Voss's latin- og realskole",
TITLE = "Bidrag til dansk-norskens lydl{\ae}re",
YEAR = "1881",
LOCATION = "Kristiania",
PAGES = "1--66",
PUBLISHER = "W. C. Fabritius"}
@INCOLLECTION{jahr2007,
AUTHOR = "Ernst H{\aa}kon Jahr",
BOOKTITLE = "{\AA} sj{\aa} samfunnet gjennom spr{\aa}ket",
EDITOR = "Gunnstein Akselberg and Johan Myking",
TITLE = "Bruk av omgrepa 'standardtalem{\aa}l', 'normalisering' og 'knot' for {\aa} skildre spr{\aa}ktilh{\o}va i Noreg i dag",
YEAR = "2007",
LOCATION = "Oslo",
PAGES = "93--98",
PUBLISHER = "Novus"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
另一个选择是遵循@Guido 的建议(也是针对我的问题在 biblatex 中将编辑姓名后跟 (Ed./Eds.) 和标题前的逗号),并使用下面的代码。这里的问题是编辑的名字没有缩写(这很自然,因为我没有在这个问题中要求它)。
\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books
%% Move names of editors before the book title, and add "(Eds.)"
\usepackage{xpatch}
\xpatchbibmacro{editorstrg}{\bibstring}{\bibcpstring}{}{}
\renewbibmacro*{in:}{
\ifentrytype{incollection}{%
\DeclareNameAlias{editor}{first-last}
\printtext{In}
\ifnameundef{editor}
{}
{\printnames{editor}%
\addspace
\mkbibparens{\usebibmacro{editorstrg}}
\setunit{\addcomma\addspace}%
}%
\printfield[book]{booktitle}
\clearfield{booktitle}
\clearname{editor}
}
{}%
}%%
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INCOLLECTION{brekke1881,
AUTHOR = "K. Brekke",
BOOKTITLE = "Indbydelsesskrift til den offentlige examen i juni og juli 1881 ved Aars og Voss's latin- og realskole",
TITLE = "Bidrag til dansk-norskens lydl{\ae}re",
YEAR = "1881",
LOCATION = "Kristiania",
PAGES = "1--66",
PUBLISHER = "W. C. Fabritius"}
@INCOLLECTION{jahr2007,
AUTHOR = "Ernst H{\aa}kon Jahr",
BOOKTITLE = "{\AA} sj{\aa} samfunnet gjennom spr{\aa}ket",
EDITOR = "Gunnstein Akselberg and Johan Myking",
TITLE = "Bruk av omgrepa 'standardtalem{\aa}l', 'normalisering' og 'knot' for {\aa} skildre spr{\aa}ktilh{\o}va i Noreg i dag",
YEAR = "2007",
LOCATION = "Oslo",
PAGES = "93--98",
PUBLISHER = "Novus"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
所以我的问题是:在缺少编辑者的情况下,我该如何修改@moewe 的建议去掉不需要的句号,或者我该如何修改@Guido 的建议来缩写编辑者的名字?
答案1
要修复我的代码,你可以修改in:
bibmacro 以
\renewbibmacro*{in:}{%
\printtext{\bibstring{in}}%
\printunit{\intitlepunct}}
也就是说,我们使用\printunit
(关于为什么我们需要使用,\printunit
可以在我的这个答案中找到解释)。
平均能量损失
\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\renewcommand*{\intitlepunct}{\space} % remove colon after "In:" for articles in books
%% Abbreviate first names of editors
\DeclareNameAlias{byeditor}{first-last-inits}
\DeclareNameFormat{first-last-inits}{%
\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}%
\usebibmacro{name:andothers}}
%%
%% Move names of editors before the book title, and add "(Eds.)"
\usepackage{xpatch}
\DeclareNameAlias{editorin}{first-last-inits}
\newbibmacro*{byeditor:in}{%
\ifnameundef{editor}
{}
{\printnames[editorin]{editor}%
\addspace\bibsentence%
\mkbibparens{\usebibmacro{editorstrg}}%
\clearname{editor}%
\printunit{\addcomma\space}}}
\xpatchbibdriver{incollection}
{\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{byeditor:in}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor}}
{}{}
%%
%% this is to fix the punctuation after "In"
\renewbibmacro*{in:}{%
\printtext{\bibstring{in}}%
\printunit{\intitlepunct}}
%%
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@INCOLLECTION{brekke1881,
AUTHOR = "K. Brekke",
BOOKTITLE = "Indbydelsesskrift til den offentlige examen i juni og juli 1881 ved Aars og Voss's latin- og realskole",
TITLE = "Bidrag til dansk-norskens lydl{\ae}re",
YEAR = "1881",
LOCATION = "Kristiania",
PAGES = "1--66",
PUBLISHER = "W. C. Fabritius"}
@INCOLLECTION{jahr2007,
AUTHOR = "Ernst H{\aa}kon Jahr",
BOOKTITLE = "{\AA} sj{\aa} samfunnet gjennom spr{\aa}ket",
EDITOR = "Gunnstein Akselberg and Johan Myking",
TITLE = "Bruk av omgrepa 'standardtalem{\aa}l', 'normalisering' og 'knot' for {\aa} skildre spr{\aa}ktilh{\o}va i Noreg i dag",
YEAR = "2007",
LOCATION = "Oslo",
PAGES = "93--98",
PUBLISHER = "Novus"}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}