我正在尝试格式化两种 Biblatex 条目类型。
对于该@incollection
条目,我想删除第一个逗号(标记为黄色)并将第二个逗号更改为句点。
对于@online
条目,我似乎无法删除日期。即使条目中没有日期字段,括号仍然会显示,但为空。我还想更改标题后的逗号'聚合物'有没有办法抑制“地址:'(德语中的“url:”)字符串?
梅威瑟:
\documentclass[11pt, oneside, a4paper, bibliography=totoc, parskip=half,
BCOR=12mm, captions=tableheading, openany, numbers=noenddot, headinclude,
liststotoc]{scrbook}
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@online{polymer2020,
title = {Polymer},
author = {{N. N.}},
journaltitle = {Wikipedia},
url = {https://de.wikipedia.org/wiki/Polymer},
urldate = {2020-02-16}
}
@incollection{hans2020,
title = {Ein {{Qualit\"atsicherungskonzept}}},
booktitle = {Additive {{Fertigung}} von {{Bauteilen}}},
author = {Hans, Peter and Werner, Meier},
editor = {Michael, Hauser},
date = {2020},
publisher = {{Springer}},
location = {{Berlin}}
}
\end{filecontents}
\usepackage[backend=biber, style=ieee, citestyle=numeric, sorting=nyt,
autocite=inline, isbn=false, dashed=false, url=false]{biblatex}
\DeclareNameAlias{sortname}{family-given}
\DeclareNameAlias{default}{family-given}
\DeclareFieldFormat[book,inbook,incollection,inproceedings]{series}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareFieldFormat*[online]{title}{\textit{#1}}
\renewcommand{\labelnamepunct}{\addcolon\space}
\renewcommand{\mkbibnamefamily}[1]{\textsc{#1}}
\renewcommand{\multinamedelim}{\addsemicolon\space}
\renewcommand{\finalnamedelim}{\addsemicolon\space}
\addbibresource{bibliography.bib}
\begin{document}
\cite{polymer2020}
\cite{hans2020}
\printbibliography
\end{document}
答案1
对于第一个逗号,@incollection
您需要重新定义editortypedelim
(例如参见删除 biblatex 中编辑器名称后的逗号和biblatex:如何删除 ed./eds. 之前的逗号?)。
句号有点棘手,在示例中,有几种方法可以在该位置生成句号,但如果条目中有更多字段,效果可能会有所不同。在这里,我决定通过 bibmacro 来操作publisher+location+date
。
缺失日期周围的括号只能通过修补驱动程序来删除(另请参见删除空年份字段 biblatex ieee 样式的括号,尽管这里提出的解决方案稍微更优雅一些)。
再次,条目中的句点@online
可以通过多种方式生成。由于我们已经修补了驱动程序,我决定以这种方式修补它,将句点直接插入 URL 之前。如果存在更多字段,结果可能会有所不同。
\documentclass[11pt, oneside, a4paper, bibliography=totoc, parskip=half, BCOR=12mm, captions=tableheading, openany, numbers=noenddot, headinclude, liststotoc]{scrbook}
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, style=ieee, citestyle=numeric, sorting=nyt,
autocite=inline, isbn=false, dashed=false, url=false]{biblatex}
\DeclareNameAlias{sortname}{family-given}
\DeclareNameAlias{default}{family-given}
\renewcommand{\mkbibnamefamily}[1]{\textsc{#1}}
\DeclareDelimFormat{multinamedelim}{\addsemicolon\space}
\DeclareDelimAlias{finalnamedelim}{multinamedelim}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}
\DeclareDelimFormat[bib]{nametitlepunct}{\addcolon\space}
\DeclareFieldFormat*[online]{title}{\textit{#1}}
\DeclareFieldFormat[book,inbook,incollection,inproceedings]{series}{#1}
\renewbibmacro*{publisher+location+date}{%
\printunit{\addperiod\space}%
\printlist{location}%
\iflistundef{publisher}
{\setunit*{\addcomma\space}}
{\setunit*{\addcolon\space}}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
\newunit}
\DeclareFieldFormat[online]{date}{\mkbibparens{#1}}
\usepackage{xpatch}
\xpatchbibdriver{online}
{\printtext[parens]{\usebibmacro{date}}}
{\usebibmacro{date}}
{}{}
\xpatchbibdriver{online}
{\newunit\newblock
\usebibmacro{url+urldate}}
{\setunit{\addperiod\space}\newblock
\usebibmacro{url+urldate}}
{}{}
\DeclareFieldFormat{url}{\url{#1}}
\begin{filecontents}{\jobname.bib}
@online{polymer2020,
title = {Polymer},
author = {{N. N.}},
journaltitle = {Wikipedia},
url = {https://de.wikipedia.org/wiki/Polymer},
urldate = {2020-02-16},
}
@incollection{hans2020,
title = {Ein Qualitätsicherungskonzept},
booktitle = {Additive Fertigung von Bauteilen},
author = {Hans, Peter and Werner, Meier},
editor = {Michael, Hauser},
date = {2020},
publisher = {Springer},
location = {Berlin},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{polymer2020}
\cite{hans2020}
\printbibliography
\end{document}