
Ich versuche, einen Bibliographiestil zu finden biblatex-philosophy
. Das Format für Online-Ressourcen ist wie folgt:
Online mit Autor:
Online ohne Autor (der Einfachheit halber dieselben Angaben):
Verwenden Sie standardmäßig diesen Code (der bereits einige Formatierungsänderungen enthält):
\documentclass[11pt, parskip=false]{scrartcl}
% Bibliography preamble
\usepackage[giveninits=true, style=philosophy-modern, yearleft=true, dateabbrev=false]{biblatex}
\addbibresource{testbib.bib}
\DeclareFieldFormat[online]{title}{#1}
\renewcommand{\postsep}{% Add comma to end of author section
\addcomma
\null\par\nobreak\vskip\postnamesep%
\hskip-\bibhang\ignorespaces}
\DeclareFieldFormat{urldate}{% Reformats urldate field to read "accessed", replacing "(visted on)"
accessed %
\thefield{urlday}\addspace
\mkbibmonth{\thefield{urlmonth}}\addspace%
\thefield{urlyear}\isdot}
\renewbibmacro*{url+urldate}{% Makes URL begin on a new line, adds comma after URL, before URLdate
\printunit{\newline}\usebibmacro{url}%
\iffieldundef{urlyear}
{}
{\setunit*{\addcomma\addspace}%
\usebibmacro{urldate}}}
\begin{document}
Sentence containing citation \parencite{blogWithoutAuthor, blogWithAuthor}.
\printbibliography
\end{document}
Mit dieser .bib
Datei:
@online{blogWithoutAuthor,
date = {2018},
title = {Historians in the News},
maintitle = {History Matters},
organization = {The University of Sydney},
url = {http://blogs.usyd.edu.au/historymatters/2018/02/historians_in_the_news_2018.html},
urldate = {2018-02-23}
}
@online{blogWithAuthor,
date = {2018},
title = {Historians in the News},
maintitle = {History Matters},
organization = {The University of Sydney},
url = {http://blogs.usyd.edu.au/historymatters/2018/02/historians_in_the_news_2018.html},
urldate = {2018-02-23},
author = {McDonnell, Mike}
}
Gibt Folgendes aus:
Wie Sie sehen, gibt es keinen Website-Titel (zusätzlich zum Seitentitel) und standardmäßig
philosophy-modern
ersetzt die Einstellung den Autor durch den Titel, wenn kein Autor vorhanden ist.
Ich habe dem obigen Code den folgenden hinzugefügt, um das Feld „maintitle“ (das als Website-Titel dient) für den online
Bibdriver erkennbar zu machen und außerdem das Autorenfeld vollständig auszuschneiden:
\usepackage{xpatch}% Modifies online bibdriver to remove author field, and add maintitle field after title
\xpatchbibdriver{online}
{\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}}
{\usebibmacro{date+extradate}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit\newblock
\usebibmacro{maintitle}%
\newunit}
{}
{\typeout{failed to remove author field, add maintitle field to driver for 'online'}}
Das Ergebnis lautet:
Großartig, außer dass ich offensichtlich keinen Autor bekomme, selbst wenn einer angegeben ist, da ich das Autormakro aus der Ausführung entfernt habe.
Meine Frage lautet: Wie führe ich den xpatch
obigen Codeausschnitt bedingt aus, also nur, wenn der Autor nicht vorhanden ist (undefiniert?), um die erforderliche Formatierung zu erreichen?
Ich versuche immer noch, den xpatch
Befehl zu verstehen, daher bezweifle ich, dass mein Versuch überhaupt optimal ist. Bitte lassen Sie mich wissen, wie der Code verbessert werden könnte.
Antwort1
Ich glaube, ich verstehe, was Sie meinen. Aber wie auch immer, die Vorgehensweise besteht nicht darin, „einen Patch bedingt auszuführen“, sondern vielmehr darin, „einen Patch mit eingeschlossener Bedingung auszuführen“.
Wenn ich es richtig verstehe, sollte dies funktionieren (beachten Sie, dass ich je nach dem betreffenden Makro das Vorhandensein von „Autor“, „Herausgeber“ oder „Übersetzer“ teste):
\documentclass[11pt, parskip=false]{scrartcl}
% Bibliography preamble
\usepackage[giveninits=true, style=philosophy-modern, yearleft=true, dateabbrev=false]{biblatex}
\addbibresource{testbib.bib}
\DeclareFieldFormat[online]{title}{#1}
\renewcommand{\postsep}{% Add comma to end of author section
\addcomma
\null\par\nobreak\vskip\postnamesep%
\hskip-\bibhang\ignorespaces}
\DeclareFieldFormat{urldate}{% Reformats urldate field to read "accessed", replacing "(visted on)"
accessed %
\thefield{urlday}\addspace
\mkbibmonth{\thefield{urlmonth}}\addspace%
\thefield{urlyear}\isdot}
\renewbibmacro*{url+urldate}{% Makes URL begin on a new line, adds comma after URL, before URLdate
\printunit{\newline}\usebibmacro{url}%
\iffieldundef{urlyear}
{}
{\setunit*{\addcomma\addspace}%
\usebibmacro{urldate}}}
\usepackage{xpatch}% Modifies online bibdriver to remove author field, and add maintitle field after title
\xpatchbibdriver{online}
{\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}}
{\ifboolexpr{
test {\ifnameundef{author}}
and
test {\ifnameundef{editor}}
and
test {\ifnameundef{translator}}
}
{\usebibmacro{date+extradate}}
{\usebibmacro{author/editor+others/translator+others}}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit\newblock
\usebibmacro{maintitle}%
\newunit}
{}
{\typeout{failed to remove author field, add maintitle field to driver for 'online'}}
\begin{document}
Sentence containing citation \parencite{blogWithoutAuthor, blogWithAuthor}.
\printbibliography
\end{document}
Antwort2
Der Titel wird als Fallback in den Makros und verwendet author
, sodass Sie nie mit einer leeren „Namensüberschrift“ enden, wenn überhaupt kein Name angegeben ist.editor
translation
Sie könnten jetzt die Ausführung des Namensdruckmakros unterdrücken, falls kein Name vorhanden ist, wie in der Antwort von gusbrs gezeigt. Aber ich bevorzuge einen anderen Ansatz: Sagen Sie den Namensdruckmakros, dass sie nicht auf den Titel zurückgreifen sollen, wenn kein Name vorhanden ist. Dies kann durch Neudefinition der Bibmacros author
, bbx:editor
und erfolgen bbx:translator
.
\documentclass[australian, 11pt, parskip=false]{scrartcl}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[giveninits=true, style=philosophy-modern, yearleft=true, dateabbrev=false, urldate=comp, uniquename=init]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{blogWithoutAuthor,
date = {2018},
title = {Historians in the News},
maintitle = {History Matters},
organization = {The University of Sydney},
url = {http://blogs.usyd.edu.au/historymatters/2018/02/historians_in_the_news_2018.html},
urldate = {2018-02-23}
}
@online{blogWithAuthor,
date = {2018},
title = {Historians in the News},
maintitle = {History Matters},
organization = {The University of Sydney},
url = {http://blogs.usyd.edu.au/historymatters/2018/02/historians_in_the_news_2018.html},
urldate = {2018-02-23},
author = {McDonnell, Mike}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\DeclareFieldFormat[online]{title}{#1}
\renewcommand{\postsep}{%
\addcomma
\null\par\nobreak\vskip\postnamesep
\hskip-\bibhang\ignorespaces}
\DefineBibliographyStrings{english}{
urlseen = {accessed},
}
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}
\renewbibmacro*{url+urldate}{%
\printunit{\newline}\newblock
\usebibmacro{url}%
\iffieldundef{urlyear}
{}
{\setunit*{\addcomma\addspace}%
\usebibmacro{urldate}}}
\makeatletter
\DeclareDelimFormat[bib,biblist]{nametitledelim}{\addcomma\space}
\renewbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{}%
{\usebibmacro{bbx:savehash}%
\printnames{author}%
\iffieldundef{nameaddon}
{}%
{\setunit{\addspace}%
\printfield{nameaddon}}%
\postsep}%
\usebibmacro{date+extradate}%
\iffieldundef{authortype}
{}%
{\usebibmacro{authorstrg}%
\printtext{\printdelim{nametitledelim}}}}%
{\global\undef\bbx@lasthash
\usebibmacro{date+extradate}}}
\renewbibmacro*{bbx:editor}[1]{%
\ifboolexpr{%
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}%
{\usebibmacro{bbx:dashcheck}%
{}%
{\printnames{editor}%
\postsep%
\usebibmacro{bbx:savehash}}%
\usebibmacro{date+extradate}%
\usebibmacro{#1}%
\clearname{editor}%
\printtext{\printdelim{nametitledelim}}}%
{\global\undef\bbx@lasthash
\usebibmacro{date+extradate}}}%
\renewbibmacro*{bbx:translator}[1]{%
\ifboolexpr{%
test \ifusetranslator
and
not test {\ifnameundef{translator}}
}%
{\usebibmacro{bbx:dashcheck}%
{}%
{\printnames{translator}%
\postsep%
\usebibmacro{bbx:savehash}}%
\usebibmacro{date+extradate}%
\usebibmacro{#1}%
\clearname{translator}%
\printtext{\printdelim{nametitledelim}}}%
{\global\undef\bbx@lasthash
\usebibmacro{date+extradate}}}%
\makeatother
\usepackage{xpatch}% Modifies online bibdriver to add maintitle field after title
\xpatchbibdriver{online}
{\usebibmacro{title}}
{\usebibmacro{title}%
\newunit\newblock
\usebibmacro{maintitle}}
{}
{\typeout{failed to add maintitle field to driver for 'online'}}
\begin{document}
Sentence containing citation \parencite{blogWithoutAuthor, blogWithAuthor, westfahl:frontier, westfahl:space}.
\printbibliography
\end{document}
Beachten Sie, wie ich die Daten im australischen Stil babel
mit der globalen Option australian
und der biblatex
Option erhalten habe urldate=comp
.