包含编辑器的条目的自定义 bib 样式

包含编辑器的条目的自定义 bib 样式

我正在尝试为网站 (@misc) 实现以下书目样式:

编辑(Hrsg.)(2015):标题、地点。适用范围: http://some.kind.of.url(上次更新:2015 年 9 月 5 日)。

我想在参考书目中添加“已下载”字段,以获取可公开获取的 PDF 文件参考书目条目:

编辑(Hrsg.)(2015):标题、地点。适用范围: http://some.kind.of.url/file.pdf(下载日期:2015 年 9 月 5 日)。

这是我迄今为止所做的事情的例子:

\documentclass[12pt, oneside]{Thesis}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[backend=biber,%
            citestyle=authoryear-icomp,%
            bibstyle=authoryear,%
            dashed=false,%
            sorting=nyvt,%
            autocite=footnote,%
            autopunct=true,%
            backrefstyle=three+,%
            isbn=false,%
            doi=false,%
            pagetracker=true,%
            useprefix=true,%
            uniquename=init,%                       
            firstinits=true,%
            maxcitenames=2,%
            ]{biblatex} 
\addbibresource{Bibliography.bib}                       
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}
\setlength{\footnotesep}{0.6\baselineskip}
\renewcommand{\mkcitation}[1]{\space#1}
\renewcommand{\mkblockquote}[4]{\singlespace\emph{#1}#2#4#3}
\urlstyle{same}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand{\multinamedelim}{\addsemicolon\space}
\renewcommand{\finalnamedelim}{\addsemicolon\space}
\DeclareNameAlias{author}{last-first}
\DeclareNameAlias{labelname}{last-first}
\DeclareFieldFormat{title}{#1}
\DeclareFieldFormat{url}{verf{\"u}gbar unter\addcolon\space\url{#1}}
\DefineBibliographyStrings{ngerman}{urlseen = letzter Zugriff\addcolon}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat{journaltitle}{#1}
\renewcommand{\bibfootnotewrapper}[1]{\bibsentence#1\addspace}
\DefineBibliographyStrings{ngerman}{
    editor = {(Hrsg\adddot)},
    editors={(Hrsg\adddot)}
}
\renewbibmacro*{editor+others}{
    \ifboolexpr{
        test \ifuseeditor
        and
        not test {\ifnameundef{editor}}
    }
    {
        \printnames{editor}%
        \setunit{\space}%
        \usebibmacro{editor+othersstrg}%
        \clearname{editor}
        \usebibmacro{date+extrayear}
    }
    {

    }
}

\begin{document}
Some Text\blockquote[{\autocite[][]{WwwSource.2015}}]{with citation}{}.
\end{document}

这是我的第一个 .bib 条目:

@misc{WwwSource.2015,
 editor = {{Editor}},
 year = {{2015}},
 title = {Title},
 url = {http://some.kind.of.url},
 keywords = {Quelle},
 address = {Location},
 urldate = {2015-09-05},
}

这是我的第二个 .bib 条目:

@misc{WwwSource.2015,
 editor = {{Editor}},
 year = {{2015}},
 title = {Title},
 url = {http://some.kind.of.url/file.pdf},
 keywords = {Quelle},
 address = {Location},
 urldate = {2015-09-05},
 downloaded = {2015-09-05}
}

我目前遇到的问题是,随着我的参考书目中宏编辑器+其他内容的重新定义,包含编辑器的条目被缩进: 在此处输入图片描述

对于带有下载日期的第二部分,我不知道该怎么做。

任何帮助均感激不尽。

提前致谢。

答案1

由于我们决定使用 来keyword决定是否显示“letzter Zugriff”或“Download am”,因此整个过程并不太复杂。我们还将了解如何使用 字段来执行此操作options,而不是使用旧的keywords

首先,我们需要定义一个新的书目字符串

\NewBibliographyString{downloadon}

然后,我们定义字符串,让它们表达正确的内容

\DefineBibliographyStrings{german}{%
  urlfrom    = {verfügbar unter},
  urlseen    = {letzter Zugriff},
  downloadon = {Download am},
}

url然后我们改变和字段的格式urldate来使用新的字符串,keywords我们需要

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \ifkeyword{pdf}
      {\bibstring{downloadon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}

urldate根据关键字是否 pdf存在,显示不同的 bibstring。

或者,我们可以使用options提供给条目。然后我们需要

\newtoggle{blx:pdf}
\DeclareEntryOption{pdf}[true]{%
  \settoggle{blx:pdf}{#1}}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \iftoggle{blx:pdf}
      {\bibstring{downloadon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}

而且您需要添加options = {pdf},到 bib 条目而不是添加keyword pdf

我们甚至可以稍微自动化一下这个过程,这样所有以 结尾的 URL 都会.pdf自动触发该pdf=true选项

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=url, match=\regexp{\.pdf\Z}, final]
      \step[fieldset=options, append, fieldvalue={,pdf=true}]
    }
  }
}

平均能量损失

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear-icomp,%
            dashed=false,%
            sorting=nyvt,%
            autocite=footnote,%
            autopunct=true,%
            backrefstyle=three+,%
            isbn=false,%
            doi=false,%
            pagetracker=true,%
            useprefix=true,%
            uniquename=init,%                       
            firstinits=true,%
            maxcitenames=2,%
            ]{biblatex} 
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@misc{WwwSource.2015,
 editor    = {Ellen Ditor},
 year      = {2015},
 title     = {A Real PDF},
 url       = {http://example.edu/file.pdf},
 keywords  = {Quelle},
 options   = {pdf},
 address   = {Location},
 urldate   = {2015-09-05},
}
@misc{WwwSource.2016,
 editor   = {Ellen Ditor},
 year     = {2016},
 title    = {Just Any Old Website},
 url      = {http://example.com},
 keywords = {Quelle},
 address  = {Location},
 urldate  = {2015-09-05},
}
\end{filecontents*}
\addbibresource{\jobname.bib}   

\renewcommand{\mkcitation}[1]{\space#1}
\renewcommand{\mkblockquote}[4]{\singlespace\emph{#1}#2#4#3}
\urlstyle{same}

\renewcommand*{\bibfootnotewrapper}[1]{\bibsentence#1\addspace}

\renewcommand*{\nameyeardelim}{\addcomma\space}
\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand*{\multinamedelim}{\addsemicolon\space}
\renewcommand*{\finalnamedelim}{\multinamedelim}

\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{labelname}{last-first}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareFieldFormat{title}{#1}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat{journaltitle}{#1}


\NewBibliographyString{downloadon}
\DefineBibliographyStrings{german}{%
  urlfrom    = {verfügbar unter},
  urlseen    = {letzter Zugriff},
  downloadon = {Download am},
}

\newtoggle{blx:pdf}
\DeclareEntryOption{pdf}[true]{%
  \settoggle{blx:pdf}{#1}}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \iftoggle{blx:pdf}
      {\bibstring{downloadon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}



\makeatletter
\renewbibmacro*{bbx:editor}[1]{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\printnames{editor}%
        \setunit{\addspace}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{editor}%
     \setunit{\addspace}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{date+extrayear}}
\makeatother

\begin{document}
Some Text \autocite{WwwSource.2015,WwwSource.2016}

\printbibliography
\end{document}

在此处输入图片描述

相关内容