将“name”数据类型添加到自定义 biblatex 输入样式

将“name”数据类型添加到自定义 biblatex 输入样式

在 @moewe 的大力帮助下,我能够设置自定义的 biblatex 样式,而且由于我还需要创建更多样式,所以我想我会在还记得该怎么做的时候尝试一下 :D

所以我的主要挑战现在要获取name要打印的数据类型。我不确定为什么,但是打印我的自定义字段producerdirector被省略了,而打印预定义的却工作得很好organization

第二个挑战正在设置条件。如果没有主标题,我希望以volume不同的方式打印(而不是在主标题和标题之间,在标题之后)。

所以不要这样:在此处输入图片描述

第一部分看起来应该是这样的: 在此处输入图片描述

这是我当前的 MWE:

% arara: lualatex: { shell: true, synctex: true }
% arara: biber
% arara: lualatex: { shell: true, synctex: true }
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@video{help,
  maintitle       = {Terasu Hausu},
  date           = {2012-02-26},
  year           = {2012},
  maintitleaddon  = {Terrace House},
  titleaddon = {Boys and Girls In The City},
  title    = {Boisu},
  volume = {2},
  seriesseason = {3},
  episode = {12},
  duration = {54 Minuten},
  director = {Maeda, Masato},
  producer = {Matsumoto, Ayaka and Peters, Greg},
  format = {Video On Demand},
  type = {TV-Mini-Series},
  fsk = {12},
  urldate        = {2019-07-21},
  url            = {https://www.netflix.com/title/80212301},
  organization   = {Netflix}
}

@video{helpshort,
  date           = {2012-02-26},
  year           = {2012},
  titleaddon = {Boys and Girls In The City},
  title    = {Boisu},
  volume = {2},
  seriesseason = {3},
  episode = {12},
  duration = {54 Minuten},
  director = {Maeda, Masato},
  producer = {Matsumoto, Ayaka and Peters, Greg},
  format = {Video On Demand},
  type = {TV-Mini-Series},
  fsk = {12},
  urldate        = {2019-07-21},
  url            = {https://www.netflix.com/title/80212301},
  organization   = {Netflix}
}
\end{filecontents*}
\begin{filecontents}{customstyles.dbx}
\DeclareDatamodelEntrytypes{video}
\DeclareDatamodelFields[type=field,datatype=literal]{
  duration,
  format,
  type,
}
\DeclareDatamodelFields[type=list,datatype=name]{
  director,
  producer,
}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  fsk,
  seriesseason,
  episode,
}
\DeclareDatamodelEntryfields[video]{
  duration,
  director,
  episode,
  format,
  fsk,
  producer,
  seriesseason,
  type,
}
\end{filecontents}
\documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
\usepackage[
  backend=biber,
  style=ext-authoryear,
  sorting=nyvt,
  datamodel=customstyles,
  maxnames=25,
  innamebeforetitle=true,
  usetranslator=true,
  alldates=terse,
  labeldate=year,
  dashed=false,
  isbn=false
]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}

  \DeclareLabeltitle[video]{%
  \field{maintitle}
  \field{shorttitle}
  \field{title}
 } 

\begin{filecontents*}{custombibstring-ngerman.lbx}
\ProvidesFile{custombibstring-ngerman.lbx}[2019/07/26]
\InheritBibliographyExtras{ngerman}
\DeclareBibliographyStrings{%
  inherit      = {ngerman},
  andothers    = {{et al\adddot}{et al\adddot}},
  byeditor     = {{herausgegeben von}{hg\adddotspace von}},
  editor       = {{Herausgeber}{Hg\adddot}},
  editors      = {{Herausgeber}{Hg\adddot}},
  urlseen      = {{letzter Abruf}{letzter Abruf}},
  duration = {{Spieldauer}{Spieldauer}},
  seriesseason = {{Staffel}{Staffel}},
  episode = {{Episode}{Episode}},
  director = {{unter der Regie von}{unter der Regie von}},
  producer = {{produziert von}{produziert von}},
  fsk = {{FSK}{FSK}},
  volume = {{Vol\adddot}{Vol\adddot}}
}
\end{filecontents*}

\NewBibliographyString{director,duration,episode,format,fsk,producer,seriesseason}
\DeclareLanguageMapping{ngerman}{custombibstring-ngerman}

\renewcommand*{\titleaddonpunct}{\addspace}
\DeclareFieldFormat{titleaddon}{\mkbibbrackets{#1}}
\DeclareFieldAlias{booktitleaddon}{titleaddon}
\DeclareFieldAlias{maintitleaddon}{titleaddon}
\DeclareFieldAlias{subtitleaddon}{titleaddon}

\DeclareFieldFormat[video]{title}{\textit{#1}\isdot}
\DeclareFieldFormat[video]{subtitle}{\textit{#1}\isdot}
\DeclareFieldFormat[video]{date}{\mkbibparens{#1}}
\DeclareFieldFormat[video]{volume}{\bibstring{volume}~#1}
\DeclareFieldFormat[video]{duration}{\bibstring{duration}~#1}
\DeclareFieldFormat[video]{format}{\mkbibparens{#1}}
\DeclareFieldFormat[video]{fsk}{\bibstring{fsk}~#1}
\DeclareFieldFormat[video]{seriesseason}{{#1}\adddot~\bibstring{seriesseason}}
\DeclareFieldFormat[video]{episode}{{#1}\adddot~\bibstring{episode}}
\DeclareListWrapperFormat[video]{organization}{\textsc{#1}}
\DeclareListWrapperFormat[video]{director}{\bibstring{director}\addcolon{\textsc{#1}}}
\DeclareListWrapperFormat[video]{producer}{\bibstring{producer}\addcolon{\textsc{#1}}}

\newbibmacro*{titles}{%
  \printfield{maintitle}%
   \setunit*{\titleaddonpunct}%
  \printfield{maintitleaddon}
  \newunit{\addspace}%
   \printfield{volume}%
  \setunit*{\addcolon\addspace} 
  \printfield{title}%
  \setunit*{\titleaddonpunct}%
  \printfield{titleaddon}
  \setunit{\addspace}%
  \printdate
}  

\newbibmacro*{format}{%  
  \printlist{organization}%
  \setunit*{\addcolon\addspace}%
  \printfield{type}%
  \setunit*{\titleaddonpunct}
   \printfield{format}%
}


\newbibmacro*{series}{%
  \printfield{seriesseason}%
  \setunit*{\addcomma\addspace}%
  \printfield{episode}%
  \setunit*{\addcolon\addspace}%
  \printlist{producer}%
  \setunit*{\adddot\addspace}%
  \printlist{director}%
  \setunit*{\addcolon\addspace}%
  \printfield{duration}%
  \setunit*{\addcomma\addspace}%
  \printfield{fsk}%
  \setunit*{\titleaddonpunct}
}

\urlstyle{same}%
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibparens{\bibstring{urlseen}\addcolon\space#1}}


\DeclareBibliographyDriver{video}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{titles}%
  \newunit\newblock
  \usebibmacro{format}%
  \newunit\newblock
  \usebibmacro{series}%
  \newunit\newblock
  \usebibmacro{url+urldate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}
\begin{document}
\nocite{*}
\cite{help}

\cite{helpshort}
\printbibliography
\end{document}

谢谢你!

答案1

\printnames姓名列表使用命令(而不是\printlist或)打印\printfield。因此,您需要类似

\newbibmacro*{tvseries}{%
  \printfield{seriesseason}%
  \setunit*{\addcomma\addspace}%
  \printfield{episode}%
  \setunit*{\addcolon\addspace}%
  \printnames{producer}%
  \setunit*{\addperiod\addspace}%
  \printnames{director}%
  \setunit*{\addcolon\addspace}%
  \printfield{duration}%
  \setunit*{\addcomma\addspace}%
  \printfield{fsk}%
  \setunit*{\titleaddonpunct}%
}

对于第二个问题,您将需要使用\iffieldundef

\newbibmacro*{titles}{%
  \iffieldundef{maintitle}
    {}
    {\printfield{maintitle}%
     \setunit*{\titleaddonpunct}%
     \printfield{maintitleaddon}
     \newunit{\addspace}%
     \printfield{volume}%
     \setunit*{\addcolon\addspace}}%
  \printfield{title}%
  \setunit*{\titleaddonpunct}%
  \printfield{titleaddon}
  \iffieldundef{maintitle}
    {\setunit{\addspace}%
     \printfield{volume}}
    {}%
  \setunit{\addspace}%
  \printdate
}  

\adddot请注意, (缩写的点)和\addperiod(句末的句号、句号)之间是有区别的。

总共

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@video{help,
  maintitle      = {Terasu Hausu},
  date           = {2012-02-26},
  year           = {2012},
  maintitleaddon = {Terrace House},
  titleaddon     = {Boys and Girls In The City},
  title          = {Boisu},
  volume         = {2},
  seriesseason   = {3},
  episode        = {12},
  duration       = {54 Minuten},
  director       = {Maeda, Masato},
  producer       = {Matsumoto, Ayaka and Peters, Greg},
  format         = {Video On Demand},
  type           = {TV-Mini-Series},
  fsk            = {12},
  urldate        = {2019-07-21},
  url            = {https://www.netflix.com/title/80212301},
  organization   = {Netflix},
}
@video{helpshort,
  date           = {2012-02-26},
  year           = {2012},
  titleaddon     = {Boys and Girls In The City},
  title          = {Boisu},
  volume         = {2},
  seriesseason   = {3},
  episode        = {12},
  duration       = {54 Minuten},
  director       = {Maeda, Masato},
  producer       = {Matsumoto, Ayaka and Peters, Greg},
  format         = {Video On Demand},
  type           = {TV-Mini-Series},
  fsk            = {12},
  urldate        = {2019-07-21},
  url            = {https://www.netflix.com/title/80212301},
  organization   = {Netflix},
}
\end{filecontents*}
\begin{filecontents}{customstyles.dbx}
\DeclareDatamodelEntrytypes{video}
\DeclareDatamodelFields[type=field,datatype=literal]{
  duration,
  format,
  type,
}
\DeclareDatamodelFields[type=list,datatype=name]{
  director,
  producer,
}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  fsk,
  seriesseason,
  episode,
}
\DeclareDatamodelEntryfields[video]{
  duration,
  director,
  episode,
  format,
  fsk,
  producer,
  seriesseason,
  type,
}
\end{filecontents}
\documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
\usepackage[
  backend=biber,
  style=ext-authoryear,
  sorting=nyvt,
  datamodel=customstyles,
  maxnames=25,
  innamebeforetitle=true,
  usetranslator=true,
  alldates=terse,
  labeldate=year,
  dashed=false,
  isbn=false
]{biblatex}
\usepackage{hyperref}


  \DeclareLabeltitle[video]{%
  \field{maintitle}
  \field{shorttitle}
  \field{title}
 } 

\begin{filecontents*}{custombibstring-ngerman.lbx}
\ProvidesFile{custombibstring-ngerman.lbx}[2019/07/26]
\InheritBibliographyExtras{ngerman}
\DeclareBibliographyStrings{%
  inherit      = {ngerman},
  andothers    = {{et al\adddot}{et al\adddot}},
  byeditor     = {{herausgegeben von}{hg\adddotspace von}},
  editor       = {{Herausgeber}{Hg\adddot}},
  editors      = {{Herausgeber}{Hg\adddot}},
  urlseen      = {{letzter Abruf}{letzter Abruf}},
  duration     = {{Spieldauer}{Spieldauer}},
  seriesseason = {{Staffel}{Staffel}},
  episode      = {{Episode}{Episode}},
  bydirector   = {{unter der Regie von}{unter der Regie von}},
  byproducer   = {{produziert von}{produziert von}},
  fsk          = {{FSK}{FSK}},
  volume       = {{Vol\adddot}{Vol\adddot}},
}
\end{filecontents*}

\NewBibliographyString{bydirector,duration,episode,format,fsk,byproducer,seriesseason}
\DeclareLanguageMapping{ngerman}{custombibstring-ngerman}

\renewcommand*{\titleaddonpunct}{\addspace}
\DeclareFieldFormat{titleaddon}{\mkbibbrackets{#1}}
\DeclareFieldAlias{booktitleaddon}{titleaddon}
\DeclareFieldAlias{maintitleaddon}{titleaddon}
\DeclareFieldAlias{subtitleaddon}{titleaddon}

\DeclareFieldFormat[video]{title}{\textit{#1}\isdot}
\DeclareFieldFormat[video]{subtitle}{\textit{#1}\isdot}
\DeclareFieldFormat[video]{date}{\mkbibparens{#1}}
\DeclareFieldFormat[video]{volume}{\bibstring{volume}~#1}
\DeclareFieldFormat[video]{duration}{\bibstring{duration}~#1}
\DeclareFieldFormat[video]{format}{\mkbibparens{#1}}
\DeclareFieldFormat[video]{fsk}{\bibstring{fsk}~#1}
\DeclareFieldFormat[video]{seriesseason}{\mkbibordinal{#1}~\bibstring{seriesseason}}
\DeclareFieldFormat[video]{episode}{\mkbibordinal{#1}~\bibstring{episode}}
\DeclareListWrapperFormat[video]{organization}{\textsc{#1}}
\DeclareNameWrapperFormat[video]{director}{\bibstring{bydirector}\addspace#1}
\DeclareNameWrapperFormat[video]{producer}{\bibstring{byproducer}\addspace#1}

\newbibmacro*{titles}{%
  \iffieldundef{maintitle}
    {}
    {\printfield{maintitle}%
     \setunit*{\titleaddonpunct}%
     \printfield{maintitleaddon}
     \newunit{\addspace}%
     \printfield{volume}%
     \setunit*{\addcolon\addspace}}%
  \printfield{title}%
  \setunit*{\titleaddonpunct}%
  \printfield{titleaddon}
  \iffieldundef{maintitle}
    {\setunit{\addspace}%
     \printfield{volume}}
    {}%
  \setunit{\addspace}%
  \printdate
}  

\newbibmacro*{format}{%  
  \printlist{organization}%
  \setunit*{\addcolon\addspace}%
  \printfield{type}%
  \setunit*{\titleaddonpunct}%
  \printfield{format}%
}


\newbibmacro*{tvseries}{%
  \printfield{seriesseason}%
  \setunit*{\addcomma\addspace}%
  \printfield{episode}%
  \setunit*{\addcolon\addspace}%
  \printnames{producer}%
  \setunit*{\addperiod\addspace}%
  \printnames{director}%
  \setunit*{\addcolon\addspace}%
  \printfield{duration}%
  \setunit*{\addcomma\addspace}%
  \printfield{fsk}%
  \setunit*{\titleaddonpunct}%
}

\urlstyle{same}%
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibparens{\bibstring{urlseen}\addcolon\space#1}}


\DeclareBibliographyDriver{video}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{titles}%
  \newunit\newblock
  \usebibmacro{format}%
  \newunit\newblock
  \usebibmacro{tvseries}%
  \newunit\newblock
  \usebibmacro{url+urldate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\cite{help}

\cite{helpshort}
\printbibliography
\end{document}

Terasu Hausu [露台别墅]。卷2:Boisu [城市里的男孩和女孩](2012 年 2 月 26 日)。 Netflix:电视迷你剧(视频点播)。 3. 员工,12. 集数:由 Ayaka Matsumoto 和 Greg Peters 制作。在前田正人 (Masato Maeda) 的监督下:播放时长 54 分钟,FSK 12。https://www.netflix.com/title/80212301(上次更新日期:2019 年 7 月 21 日)。//Boisu [城市男孩和女孩] Vol. 2(2012年2月26日)。 Netflix:电视迷你剧(视频点播)。 3. 员工,12. 集数:由 Ayaka Matsumoto 和 Greg Peters 制作。在前田正人 (Masato Maeda) 的监督下:播放时长 54 分钟,FSK 12。https://www.netflix.com/title/80212301(上次更新时间:2019 年 7 月 21 日)。

相关内容