自定义 biblatex

自定义 biblatex

我在自定义自己的biblatex样式时遇到了问题。它应该是这样的:

所需输出的屏幕截图,下面是适当的描述

我读完后在周末尝试了一下手动的邮政。我认为自定义现有样式(我的示例样式)会更容易,authortitle但也许创建新样式会更容易。但我只收到错误,而且截止日期的压力很大,所以我希望有人能帮助我。

编辑:需要改变的事情:

一般来说:

  1. 日期格式:dd.mm.yyyy。

文章:

  1. 删除“在:”
  2. 期刊名称、年份、期号、(全部斜体)页码。

口试(面试):

  1. 显示采访者
  2. 在面试官姓名前添加:面试:[面试官姓名]
  3. 日期,地址。

电子的:

  1. 标题用引号引起来,而不是斜体
  2. 删除“URL:”
  3. 删除“上次访问时间”的括号
  4. 显示机构

我添加了一个 MWE 和我的众多方法之一来定制authortitle样式(该方法将非常无用)。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[style=authortitle]{biblatex}
\usepackage[ngerman]{babel}

\usepackage{filecontents}

\begin{filecontents}{test.bib}
@article{article,
    author  = {Peter Adams}, 
    title   = {The title of the work},
    journal = {The name of the journal},
    year    = 1993,
    number  = 2,
    pages   = {201-213},
}

@book{book,
    author    = {Peter Babington}, 
    title     = {The title of the work},
    address = {Berlin},
    year      = 1993,
}

@Oral{dean,
  author      = {Dean Rusk},
  interviewer = {David O'Brian},
  date        = {21.08.1970},
  year        = {1970},
  address     = {Boston},
}

@Electronic{pan,
  author      = Phlip Pan
  institution = {The New York Times},
  date        = {118.11.2018},
  year        = {2016},
  title       = {The West was sure the Chinese approach would not work. It 
   just had to wait. It's still waiting.},
  url         = 
  {https://www.nytimes.com/interactive/2018/11/18/world/asia/china- 
  rules.html},
  urldate     = {18.11.2018},
}
\end{filecontents}

\addbibresource{test.bib}

\begin{document}
Some famous linguists wrote a couple of books  \cite{article} \cite{book} 


\printbibliography
\end{document}

答案1

要求实现整个风格的问题总是有点难以回答,而且需要很多时间,通常是很多询问风格的具体特征是一个更好的主意。biblatex风格的分隔性质通常允许轻松组合答案(如果不是这种情况,总是可以提出关于组合两个答案的新后续问题)。在过去的几天里,有一系列问题似乎有助于建立这里显示的风格,所以我想我会在这里收集答案以确保这个问题有答案。

首先,您的文件中有几个语法错误.bib。字段中的日期date必须采用 ISO 8601/EDTF 格式 ( yyyy-mm-dd),因此urldate = {18.11.2018},是错误的,应该是urldate = {2018-11-18},。这应该可以立即解决日期问题。不过您可能想使用选项dateabbrev=false

author此外,中的字段存在问题pan,必须是author = {Phlip Pan},

您也不应该同时提供 ayear和 adate字段。date单独提供就足够了。

我们最终得到

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{article,
  author  = {Peter Adams}, 
  title   = {The title of the work},
  journal = {The name of the journal},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
}
@book{book,
  author    = {Peter Babington}, 
  title     = {The title of the work},
  address   = {Berlin},
  year      = 1993,
}
@interview{dean,
  interviewee = {Dean Rusk},
  interviewer = {David O'Brian},
  date        = {1970-08-21},
  address     = {Boston},
}
@online{pan,
  author       = {Phlip Pan},
  organization = {The New York Times},
  date         = {2018-11-18},
  title        = {The West was sure the Chinese approach would not work.
                  It just had to wait. It's still waiting.},
  url          = {https://www.nytimes.com/interactive/2018/11/18/world/asia/china-rules.html},
  urldate      = {2018-11-18},
}
\end{filecontents}
\begin{filecontents}{interview.dbx}
\DeclareDatamodelEntrytypes{interview}
\DeclareDatamodelFields[type=list,datatype=name]{
  interviewer,
  interviewee,
}

\DeclareDatamodelEntryfields[interview]{
  addendum,
  doi,
  eprint,
  eprintclass,
  eprinttype,
  interviewer,
  interviewee,
  location,
  note,
  pubstate,
}
\end{filecontents}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[german=swiss]{csquotes}
\usepackage[backend=biber, datamodel=interview, style=authortitle, dateabbrev=false]{biblatex}

% https://tex.stackexchange.com/q/10682/35864
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}

\DeclareFieldFormat[article,periodical]{date}{\mkbibemph{#1}}
\DeclareFieldFormat[article,periodical]{volume}{\mkbibemph{#1}}
\DeclareFieldFormat[article,periodical]{number}{\mkbibemph{#1}}
\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\addcomma\space}%
  \iffieldundef{series}
    {}
    {\newunit
     \printfield{series}%
     \setunit{\addcomma\space}}%
  \usebibmacro{date}%
  \setunit{\addcomma\space}%
  \usebibmacro{volume+number+eid}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}

\DeclareFieldFormat[article,periodical]{pages}{#1}

% https://tex.stackexchange.com/q/464756/35864
\NewBibliographyString{interview}
\DefineBibliographyStrings{german}{%
  interview   = {Interview},
}

\DeclareNameAlias{interviewee}{author}

\DeclareBibliographyDriver{interview}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printnames{interviewee}%
  \newunit\newblock
  \bibstring{interview}%
  \setunit{\addspace}%
  \printnames{interviewer}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{location+date}%
  \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}}

\DeclareSortingTemplate{nty}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{interviewee}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
}

\DeclareLabelname{%
  \field{shortauthor}
  \field{author}
  \field{shorteditor}
  \field{editor}
  \field{translator}
  \field{interviewee}
}

\renewbibmacro*{cite:title}{%
  \printtext[bibhyperref]{%
    \ifentrytype{interview}
      {\bibstring{interview}%
       \setunit{\addspace}%
       \printnames[family]{interviewer}}
      {\printfield[citetitle]{labeltitle}}}}


% https://tex.stackexchange.com/q/464205/35864
\DefineBibliographyStrings{english}{
  urlseen = {visited at} 
} 



\DeclareFieldFormat[online]{title}{\mkbibquote{#1\isdot}}
\DeclareListWrapperFormat{organization}{\mkbibemph{#1}}

\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}

% https://tex.stackexchange.com/q/464383/35864
\renewbibmacro*{url+urldate}{%
  \usebibmacro{url}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\newunitpunct}%
     \usebibmacro{urldate}}}

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \newunit\newblock
  \printlist{organization}%
  \newunit\newblock
  \usebibmacro{date}%
  \newunit\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \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}}




\addbibresource{\jobname.bib}

\begin{document}
Lorem  \cite{article} ipsum \cite{book,dean,pan} 
\printbibliography
\end{document}

Adams, Peter。《作品名称》。期刊名称,1993 年,第 2 期,第 201–213 页。//Babington, Peter。《作品名称》。柏林,1993 年。//Pan, Phlip。纽约时报。2018 年 11 月 18 日。《西方确信中国的方法行不通。它只能等待。它仍在等待。》https://www.nytimes.com/interactive/2018/11/18/world/asia/china-rules.html。2018 年 11 月 18 日。//Rusk, Dean。采访 David O'Brian。波士顿,1970 年 8 月 21 日。

可能缺少一些细节,但这应该能捕捉到风格的整体感觉。

相关内容