自定义 biblatex 样式 authoryear - 第 2 部分

自定义 biblatex 样式 authoryear - 第 2 部分

这是一个后续问题自定义 biblatex 样式 authoryear

为了我的工作我需要修改另外三种类型的文献:

@inbook:

姓氏,名字(年份):书名。最后一个书籍作者姓名,第一个书籍作者姓名(年份):书名,页数。地点,出版商。

这里,“In”和“(Hg)”应该是硬编码的(这是德语)。我设法通过以下方式取消了书名和书名括号的斜体样式:

\DeclareFieldFormat[inbook]{booktitle}{#1}
\DeclareFieldFormat[inbook]{title}{#1}

但这就是全部了。

@文章:

姓氏,名字(年份):标题。期刊标题,编号(系列),页数。

@在线的:

姓氏,名字(年份):头衔,(查找日期)。网址。

这里,“besucht am”应该是硬编码的,但没问题,因为它是德语的 biblatex 标准。

我可以想象这一切并不是那么简单。。但如果能得到任何帮助,我将不胜感激!非常感谢!

我目前拥有的:

\usepackage[style=authoryear]{biblatex}
\addbibresource{sources.bib}

\DeclareFieldFormat[book]{title}{#1} %titel non-italic
\DeclareFieldFormat[inbook]{booktitle}{#1} %booktitle non-italic
\DeclareFieldFormat[inbook]{title}{#1} %title without ""
\DeclareFieldFormat[article]{title}{#1} %title without ""
\DeclareFieldFormat[article]{journaltitle}{#1} %journaltitle non-italic
\DeclareFieldFormat[online]{title}{#1} %title non-italic

\renewbibmacro*{publisher+location+date}{%
\printlist{location}%
\setunit{\addcomma\space}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
\newunit}

\renewcommand{\labelnamepunct}{\addcolon\space}

\begin{document}
\parencite{heybook}
\parencite{heyinbook}
\parencite{heyarticle}
\parencite{heyonline}
\printbibliography[heading=bibintoc]
\end{document}

我的带有示例的 sources.bib 文件如下所示:

@book{heybook,
author    ={Simon Beck},
title     ={Buchtitel},
publisher ={Verlag},
location  ={Ort},
date      ={2011} }

@inbook{heyinbook,
bookauthor={Simonbook Beckbook},
author    ={Simoninbook Beckinbook},
booktitle ={Buchtitel},
title     ={Kapiteltitel},
publisher ={Verlag},
location  ={Ort},
pages     ={123-124},
date      ={2012} }

@article{heyarticle,
author   ={Simonarticle Beckarticle},
title    ={Artikeltitel},
journaltitle={Zeitschrift},
number   ={12},
series    ={Jahrgang},
pages    ={123-124},
date     ={2013} }

@online{heyonline,
author   ={Simononline Beckonline},
title    ={Onlinetitle},
url      ={http://pes.ee.ethz.ch},
urldate  ={2014-04-12},
date     ={2014} }

答案1

好的,看看你更新后的 MWE:

\documentclass[a4 paper,12pt]{article}
\usepackage[style=authoryear,dashed=false]{biblatex}
\usepackage[ngerman]{babel} 

\begin{filecontents}{mybib.bib}
@book{heybook,
author    ={Simon Beck},
title     ={Buchtitel},
publisher ={Verlag},
location  ={Ort},
date      ={2011} }

@inbook{heyinbook,
% bookauthor={Simonbook Beckbook},
author    ={Simoninbook Beckinbook},
editor    ={Fritz HerausgeberGuy and Frieda HerausgeberGirl},
booktitle ={Buchtitel},
title     ={Kapiteltitel},
publisher ={Verlag},
location  ={Ort},
pages     ={123-124},
date      ={2012} }

@article{heyarticle,
author   ={Simonarticle Beckarticle},
title    ={Artikeltitel},
journaltitle={Zeitschrift},
number   ={12},
series    ={Jahrgang},
pages    ={123-124},
date     ={2013} }

@online{heyonline,
author   ={Simononline Beckonline},
title    ={Onlinetitle},
url      ={http://pes.ee.ethz.ch},
urldate  ={2014-04-12},
date     ={2014} }
\end{filecontents}


\addbibresource{mybib.bib}
\DeclareFieldFormat[book]{title}{#1} %titel non-italic
\DeclareFieldFormat[inbook]{booktitle}{#1} %booktitle non-italic


%my code:
\DeclareFieldFormat[inbook]{title}{#1} %title without ""
\DeclareFieldFormat[article]{journaltitle}{#1} %non-italic
\DeclareFieldFormat[online]{title}{#1} %non-italic
\DeclareFieldFormat[article]{title}{#1} %titel unquoted

\renewcommand{\intitlepunct}{}%no ":" after "in"

\DefineBibliographyStrings{german}{%redefine strings
editor= {Hg},%if you want to add a dot, add \adddot 
editors = {Hgg}
}


\renewbibmacro*{editor+others}{%from biblatex.def, parencites around editor
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\printnames{editor}%
     \addspace%
     \mkbibparens{\usebibmacro{editor+othersstrg}}%add parens
     \clearname{editor}}
    {}}



\DeclareBibliographyDriver{inbook}{%from standard.bbx; macro "editor..." instead of "byeditor..."
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{bybookauthor}%
  \newunit\newblock
  \setunit{\addspace}\newblock%added
  \usebibmacro{editor+others}%added
  \setunit{\addcolon\addspace}%added
  \usebibmacro{maintitle+booktitle}%moved
  \setunit{\addcomma\addspace}\newblock%moved
  \usebibmacro{chapter+pages}%moved
  % \newunit\newblock
  % \usebibmacro{byeditor+others}%
  % \newunit\newblock
  % \printfield{edition}%maybe add again if needed
  \newunit
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}



\DeclareBibliographyDriver{article}{%from standard.bbx, removed macro "in:"
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  % \usebibmacro{in:}%
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}   


 \newbibmacro*{journal+issuetitle}{%standard.bbx, rearranged, parencites
  \usebibmacro{journal}%
  \setunit*{\addcomma\addspace}%
  \printfield{number}%
  \setunit{\addspace}%
  %end
  \iffieldundef{series}
    {}
    {%\newunit
     \printfield[parens]{series}%
     % \setunit{\addspace}}%
     }  
  \setunit{\addspace}%
  \usebibmacro{issue+date}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}


\DeclareBibliographyDriver{online}{%arrange, deleted some macros
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \setunit{\addcomma\addspace}%modified
  \usebibmacro{url+urldate}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\renewbibmacro*{url+urldate}{%from biblatex.def, rearranged
  \iffieldundef{urlyear}
    {}
    {\printurldate}
  \setunit{\addperiod\addspace}%added
  \printfield{url}%moved
}


%your code
\renewbibmacro*{publisher+location+date}{%
\printlist{location}%
\setunit{\addcomma\space}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
\newunit}

\renewcommand{\labelnamepunct}{\addcolon\space}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

这是相当多的代码。可能有更好的方法来实现你想要的功能,但它为你提供了一个开始。我已经注释了代码;在某些部分,它可能不是最好的,你必须根据自己的需要进行修改。一些注意事项:

  • 您应该使用editor(Herausgeber)而不是bookauthor
  • 您的引用风格不一致,但这不是 LaTeX 问题......
  • 如果您想引用书中的文章,请考虑将两者都放入 bibtex 文件中,并通过 在文章中引用它crossref={key}。这样您可以更好地分离事物,而不必一次又一次地写入数据。例如,如果您将书籍条目中的字段放入并在文章中使用booktitle,这将自动继承。titlecrossref
  • 更新后的 MWE 还将 bibfile 作为filecontent.


输出:

输出

相关内容