![biblatex - 每个单元后面都有一个逗号和空格(style=authoryear)](https://linux22.com/image/267211/biblatex%20-%20%E6%AF%8F%E4%B8%AA%E5%8D%95%E5%85%83%E5%90%8E%E9%9D%A2%E9%83%BD%E6%9C%89%E4%B8%80%E4%B8%AA%E9%80%97%E5%8F%B7%E5%92%8C%E7%A9%BA%E6%A0%BC%EF%BC%88style%3Dauthoryear%EF%BC%89.png)
我想在参考书目条目中的每个单元后面都加一个逗号,年份除外,条目末尾也是如此。我该如何实现?
这是我目前所拥有的。
\usepackage[
language=auto,
style=authoryear,
backend=bibtex,
hyperref=true,
isbn=false,
doi=false,
citereset=chapter,
maxcitenames=3,
dashed=false,
sorting=nyt,
block=par,
natbib=true, %faking natbib-commands
firstinits=true,
terseinits=false
maxbibnames=99,
autopunct=true
]{biblatex}
\DeclareBibliographyDriver{book}{%
\printnames{author}%
\newunit
\printfield{year}%
\newunit\newblock
\printfield{title}%
\newunit
\printlist{edition}%
\newunit
\printlist{publisher}%
\newunit
\printlist{location}%
\finentry}
%\DeclareBibliographyDriver{article}{%
%\printnames{author}%
%\newunit
%\printfield{year}%
%\newunit\newblock
%\printfield{title}%
%\newunit
%\printlist{edition}%
%\newunit
%\printlist{journal}%
%\newunit
%\printlist{location}%
%\finentry}
%% Jahresangabe bei Referenzen in Biblipographie fett
\DeclareFieldFormat{year}{\bfseries{(#1)}}
%% Jahresangabe bei Referenzen im Dokument nicht fett
\DeclareFieldFormat{labelyear}{(#1)}
%% Zeilenumbruch vor Ausgabe der URL bei Internetquellen
\DeclareFieldFormat{url}{\newline URL: \url{#1}}
%% Ausgabe des letzten Seitenbesuchs nach Richtlinien
\DeclareFieldFormat{urldate}{(Last Visit: \urldate{#1})}
\DefineBibliographyStrings{american}{%
bibliography = {Bibliography},
shorthands = {Abbreviations},
editor = {editor},
editors = {editors},
}
\renewcommand*{\bibpagespunct}{%
\ifentrytype{article,inbook,incollection,inproceedings,patent,thesis,unpublished,online}{\addspace}{\addcomma\space}}
%% no indent
\setlength{\bibhang}{0pt}
%% eine Leerzeile zwischen zwei Bib-Einträgen
\setlength{\bibitemsep}{12pt}
%% Doppelpunkte nach dem Datum sicherstellen
\renewcommand{\labelnamepunct}{\addcolon}
\renewcommand{\intitlepunct}{\addcolon}
%% Names... Lastname, Firstname
\DeclareNameAlias{sortname}{last-first}
%% Format der Titelausgabe im Dokument bei Referenzen auf normal setzen
\DeclareFieldFormat{citetitle}{#1\isdot}
\DeclareFieldFormat[article,inbook,incollection,inproceedings,patent,thesis,unpublished,online]{citetitle}{#1}
%% Format der Titelausgabe in Bibliographie
\DeclareFieldFormat{title}{#1\isdot}
\DeclareFieldFormat[article,inbook,incollection,inproceedings,patent,thesis,unpublished,online]{title}{#1}
\AtBeginBibliography{%
%% auschließlich Slash zwischen den Autorennamen
\renewcommand{\multinamedelim}{/}
\renewcommand{\finalnamedelim}{/}
%% auschließlich Slash zwischen den Orten
\renewcommand{\multilistdelim}{/}
\renewcommand{\finallistdelim}{/}
%% alle Teile der Autoren fett formatieren
\renewcommand*{\mkbibnamefirst}[1]{\bfseries{#1}}
\renewcommand*{\mkbibnamelast}[1]{\bfseries{#1}}
\renewcommand*{\mkbibnameprefix}[1]{\bfseries{#1}}
\renewcommand*{\mkbibnameaffix}[1]{\bfseries{#1}}
}
\addbibresource{Bibliography/SA-bib}
我以为
\renewcommand*{\bibpagespunct}{%
\ifentrytype{article,inbook,incollection,inproceedings,patent,thesis,unpublished,online}{\addspace}{\addcomma\space}}
会朝着正确的方向发展,但仅此而已。
我还有一些其他具体问题,但如果可以的话,我打算为每个问题开一个帖子。此外,如果有人想就改进配置提出意见,我也很乐意接受。
答案1
您的驱动程序使用\newunitpunct
而不是\labelnamepunct
,因此您无法在作者年份标签后合并不同的单位标点符号。您可能更愿意定制标准驱动程序,而不是完全重写驱动程序。使用 egreg 的xpatch
软件包,这项任务变得特别容易,它(除其他外)etoolbox
将 的修补命令扩展到参考书目宏、驱动程序、格式化指令和索引指令。
\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear,uniquename=init,firstinits]{biblatex}
\usepackage{xpatch}
\renewcommand*{\newunitpunct}{\addcomma\space}
% bold bibliography "label" followed by colon and linebreak
\renewbibmacro*{begentry}{\mkbibbold\bgroup}
\xapptobibmacro{date+extrayear}{\addcolon\egroup}{}{}
\renewcommand*{\labelnamepunct}{\par\nobreak}
% redefine string preceding urldate
\DefineBibliographyStrings{american}{%
urlseen = {last visit\addcolon}}
% linebreak before URLs
\xpretobibmacro{url+urldate}{\setunit{\newunitpunct\par\nobreak}}{}{}
% some additional bibliography formatting
\DeclareNameAlias{sortname}{last-first}
\setlength{\bibhang}{0pt}
\setlength{\bibitemsep}{\baselineskip}
\AtBeginBibliography{%
\renewcommand{\multinamedelim}{\addslash}%
\renewcommand{\finalnamedelim}{\addslash}%
\renewcommand{\multilistdelim}{\addslash}%
\renewcommand{\finallistdelim}{\addslash}}
\addbibresource{biblatex-examples.bib}
\begin{document}
Filler text \parencite{companion,ctan,jaffe}.
\printbibliography
\end{document}