Biblatex 中新条目类型的小问题

Biblatex 中新条目类型的小问题

按照 (这张票)我试图弄清楚如何创建一个新的 BibLaTeX 条目类型,并设法获得了可运行的 MWE。

然而,我还需要做一些修改,但我不知道如何以及从哪里开始。

这是我当前的 MWE:

% arara: lualatex: { shell: true, synctex: true }
% arara: biber
% arara: lualatex: { shell: true, synctex: true }

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@law{se:l3help,
  lawtitle   = {Kaisei minp\={o} j\={o}bun},
  date = {2012-02-26},
  year   = {2012},
  lawtitleaddon    = {{\"U}berarbeiteter Gesetzestext des Zivilgesetzbuchs},
  lawsubtitle = {Tsuika},
  maintitle = {testmaintitle},
  maintitleaddon = {testmaintitleaddon},
  urldate = {2019-07-21},
  url = {http://dl.ndl.go.jp/info:ndljp/pid/1275567},
  organization = {Saik\={o}-saiban-sho},
  paragraph = {5},
  subparagraph = {3}, 
  number = {2}
}
\end{filecontents*}
% DBX ___________________________________________________________________________________
\begin{filecontents}{customstyles.dbx}
\DeclareDatamodelFields[type=field, datatype=literal]{
  journaltitleaddon}

\DeclareDatamodelEntryfields[article,periodical]{
  journaltitleaddon}

\DeclareDatamodelEntrytypes{law}
\DeclareDatamodelFields[type=field,datatype=literal]{
  lawsubtitle,  lawsubtitle,
  lawtitle,
  lawtitleaddon,
}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  paragraph,
  subparagraph,
  article,
}
\DeclareDatamodelEntryfields[law]{
  paragraph,
  subparagraph,
  article,
  lawsubtitle,
  lawtitle,
  lawtitleaddon,
}
\end{filecontents}
% DBX ___________________________________________________________________________________
\documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage{showframe}
\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}

% editor and et al. spelling
\DefineBibliographyStrings{german}{
  andothers = {et al\adddot},
  byeditor    = {Hg\adddotspace von},
  editor    = {Hg\adddot},
  editors   = {Hg\adddot},
  urlseen = {letzter Abruf},
}
% LBX ___________________________________________________________________________________
\begin{filecontents*}{custombibstrings.lbx}
  \ProvidesFile{custombibstrings.lbx}[2014/05/07 english with additions for law]
  \InheritBibliographyExtras{ngerman}
  \NewBibliographyString{paragraph,subparagraph,article}
  \DeclareBibliographyStrings{%
    inherit   = {ngerman},
    paragraph = {{Paragraph}{\S}},
    subparagraph = {{Absatz}{Abs.}},
    article = {{Artikel}{Art.}}
  }
\end{filecontents*}
% LBX ___________________________________________________________________________________
\DeclareLanguageMapping{ngerman}{custombibstrings}

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

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

\DeclareFieldFormat[law]{lawtitle}{#1\isdot}

   \newbibmacro*{lawtitles}{%
 \printfield{lawtitle}%
 \setunit{\adddot\addspace}
  \printfield{lawsubtitle}%
  \setunit{\addspace}%
  \printfield{lawtitleaddon}
   \setunit{\addspace}%
  {\printtext[parens]{%
  \printdate}}%
  \setunit{\adddot\addspace}%
   {\printtext[smallcaps]{%
   \printlist{organization}}}
   \setunit{\addcolon\addspace}%
   {\printtext[italics]{%
   \printfield{maintitle}}}
   \setunit{\addspace}%
  \printfield{maintitleaddon}
   \setunit{\addspace}%
}

\renewbibmacro*{paragraphs}{%
  {\printtext{%
  \bibstring{paragraph}%
  \setunit{\addspace}%
    \printfield{paragraph}}}%
  \ifnameundef{paragraph}%
    {}
    {\printtext{%
       \bibstring{article}%
       \setunit{\addspace}%
       \printfield{article}}}%
  \setunit{\addcomma\addspace}%
 \bibstring{subparagraph}%
  \setunit{\addspace}%
  \printfield{subparagraph}%
  \setunit{\addcomma\addspace}%
   \bibstring{number}%
  \setunit{\addspace}%
  \printfield{number} 
}

\newbibmacro*{url}{%
  \printfield{url}%
  \setunit{\addspace}
  \printfield{urldate}%
}


\DeclareBibliographyDriver{law}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{lawtitles}%
  \newunit\newblock
  \usebibmacro{paragraphs}%
  \newunit\newblock
  \usebibmacro{url}%
   \newunit\newblock
  \usebibmacro{finentry}}



\begin{document}
\nocite{*}
\cite{se:l3help}

\printbibliography
\end{document}

电流输出

  1. 如果能显示该字段,而不是maintitle,那就太好了。lawtitle

  2. 换行稍微偏离了一点。

  3. 我已经设法使 bibstring 工作并且article现在paragraph也可以正确显示!但是,ifundef如果我使用的话,显然参数设置不正确article

  4. 在 URL 后面应该会打印出urldate具有特定样式的内容,请参阅

    这里

    我想知道有关在线资源的设置是否可以重复使用(这就是为什么我在代码中添加了以下代码片段,但它只是有助于不在 url 前面显示文本“url:”)

    \urlstyle{same}% 
    \DeclareFieldFormat{url}{\url{#1}}
    \DeclareFieldFormat{urldate}{\mkbibparens{\bibstring{urlseen}\addcolon\space#1}}
    
  5. 有点不相关,但我想知道,是否可以按照我刚才的方式“合并” dbx 文件 - (基本上在其中添加了我现有的 dbx 文件内容journaltitleaddon)。

如果您能帮助我,我将永远感激不尽!

抱歉,我反复提问,但对我来说,这是改进的唯一方法,我很高兴在您的帮助下成功创建了一个可以运行的 MWE!

答案1

  1. authoryear样式在引文中找不到要使用的authoreditor并且也没有后备label字段时,它会返回到labeltitlelabeltitle是一个人工字段,它会自动从几个可用的标题字段中生成。默认定义为

    \DeclareLabeltitle{%
      \field{shorttitle}
      \field{title}
      \field{maintitle}
    }
    

    这只是意味着biblatex按该顺序尝试字段并设置labeltitle为第一个不为空的字段。因此,我们得到了maintitleMWE。如果您想lawtitle在这里发挥作用,您可以重新定义字段的优先顺序

    \DeclareLabeltitle[law]{%
      \field{shorttitle}
      \field{title}
      \field{lawtitle}
      \field{maintitle}
    }
    

    inslaw方括号表示此定义仅适用于@law条目。

  2. 这是自动生成的参考书目中常见的问题。请查看如何调整参考书目的断行?讨论类似情况并提出几种可能的解决方法。(此问题与此处讨论的其他问题没有根本关系,因此如果链接的讨论对您没有帮助,我建议您只提出有关换行符的新问题。)

  3. 我不太清楚你的意思,但是\iffieldundef和朋友有一些陷阱。首先,你需要知道查询字段的数据类型。有(正确的)字段、列表和名称列表。它们分别用、、、进行查询。\iffieldundef{<field>}(标准数据模型中字段的类型在文档中记录。对于自定义数据模型,你知道类型,因为你必须指定它。)日期字段是特殊的,因为它们由后端解析和分解。这意味着你必须使用而不是。\iflistundef{<list>}\ifnameundef{<name list>}biblatex\iffieldundef{date}\iffieldundef{year}

  4. 一切已为此设置好。不要重新定义 bibmacrourl并调用,\usebibmacro{url+urldate}而不是简单的\usebibmacro{url},它只会打印 URL。

  5. 是的,按照你的方式合并多个文件是可以的.dbx。根据你是否觉得\DeclareDatamodelFields按“主题”分开更自然(字段journaltitleaddon等一对一@law),你可能希望将\DeclareDatamodelFields声明分开(就像现在这样)或合并它们以获得更紧凑的感觉。biblatex无所谓。

修正的 MWE

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@law{se:l3help,
  lawtitle       = {Kaisei minp\={o} j\={o}bun},
  date           = {2012-02-26},
  year           = {2012},
  lawtitleaddon  = {{\"U}berarbeiteter Gesetzestext des Zivilgesetzbuchs},
  lawsubtitle    = {Tsuika},
  maintitle      = {testmaintitle},
  maintitleaddon = {testmaintitleaddon},
  urldate        = {2019-07-21},
  url            = {http://dl.ndl.go.jp/info:ndljp/pid/1275567},
  organization   = {Saik\={o}-saiban-sho},
  paragraph      = {5},
  subparagraph   = {3},
  number         = {2},
}
@article{Ueda.2005,
 title             = {Heian-ky\={o} no seiritsu to higashiajia},
 titleaddon        = {Die Errichtung von Heian-ky\={o} und Ostasien},
 journaltitle      = {Kodai higashi ajia no rekishi to bunka},
 journaltitleaddon = {Geschichte und Kultur im ostasiatischen Altertum},
 author            = {Ueda, Masaaki},
 year              = {2005},
 volume            = {122},
 publisher         = {Higashiajia no kodai bunka kodai-gaku kenky\={u}-jo},
 location          = {Japan},
 pages             = {2-8},
 Catalogue-Link*   = {http://iss.ndl.go.jp/books/R000000004-I7260043-00}
}

\end{filecontents*}
\begin{filecontents}{customstyles.dbx}
\DeclareDatamodelFields[type=field, datatype=literal]{
  journaltitleaddon}

\DeclareDatamodelEntryfields[article,periodical]{
  journaltitleaddon}

\DeclareDatamodelEntrytypes{law}
\DeclareDatamodelFields[type=field,datatype=literal]{
  lawsubtitle,
  lawtitle,
  lawtitleaddon,
}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  paragraph,
  subparagraph,
  article,
}
\DeclareDatamodelEntryfields[law]{
  paragraph,
  subparagraph,
  article,
  lawsubtitle,
  lawtitle,
  lawtitleaddon,
}
\end{filecontents}
\documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage{showframe}
\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}


\begin{filecontents*}{custombibstring-ngerman.lbx}
\ProvidesFile{custombibstring-ngerman.lbx}[2019/07/26 english with additions for law]
\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}},
  paragraph    = {{Paragraph}{\S}},
  subparagraph = {{Absatz}{Abs\adddot}},
  article      = {{Artikel}{Art\adddot}},
}
\end{filecontents*}


\DeclareLabeltitle[law]{%
  \field{shorttitle}
  \field{title}
  \field{lawtitle}
  \field{maintitle}
}

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


\NewBibliographyString{paragraph,subparagraph,article}
\DeclareLanguageMapping{ngerman}{custombibstring-ngerman}

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


\DeclareFieldFormat[law]{lawtitle}{#1\isdot}
\DeclareFieldFormat[law]{date}{\mkbibparens{#1}}
\DeclareListWrapperFormat[law]{organization}{\textsc{#1}}

\newbibmacro*{lawtitles}{%
  \printfield{lawtitle}%
  \setunit{\subtitlepunct}%
  \printfield{lawsubtitle}%
  \setunit{\titleaddonpunct}%
  \printfield{lawtitleaddon}
  \setunit{\addspace}%
  \printdate
  \newunit
  \printlist{organization}%
  \setunit{\addcolon\addspace}%
  \printfield{maintitle}%
  \setunit{\titleaddonpunct}%
  \printfield{maintitleaddon}%
}

\DeclareFieldFormat[law]{article}{\bibstring{article}~#1}
\DeclareFieldFormat[law]{paragraph}{\bibstring{paragraph}~#1}
\DeclareFieldFormat[law]{subparagraph}{\bibstring{subparagraph}~#1}
\DeclareFieldFormat[law]{number}{\bibstring{number}~#1}

\newbibmacro*{paragraphs}{%
  \printfield{article}%
  \setunit*{\addcomma\space}%
  \printfield{paragraph}%
  \setunit{\addcomma\space}%
  \printfield{subparagraph}%
  \setunit*{\addcomma\space}%
  \printfield{number}%
}

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


\DeclareBibliographyDriver{law}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{lawtitles}%
  \newunit\newblock
  \usebibmacro{paragraphs}%
  \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{se:l3help}

\printbibliography
\end{document}

开成民进党职分。 Tsuika [民事法典概要](2012 年 2 月 26 日)。查看完整内容:testmaintitle [testmaintitleaddon]。 §5,摘要。 3,号2. http://dl.ndl.go.jp/info:ndljp/pid/1275567(上次更新时间:2019 年 7 月 21 日)。

我对您的代码做了一些修改。大多数修改都是因为我更愿意\iffieldundef尽可能避免使用和朋友。如果字段仅通过biblatex打印和格式化,则非常适合处理缺失字段。通常这需要将格式和移动到 中。\printfield\DeclareFieldFormat\printtext\bibstring\DeclareFieldFormat

关于日期字段的最后一点说明:如上所述,date字段是特殊的。在.bib文件中,日期最好在date字段中给出(yearmonth保留以便与 BibTeX 向后兼容)。date然后解析并拆分为其组件,以便 LaTeX 可以更轻松地解析它。LaTeX 只能看到分解的日期部分(year,,,...)。不(完全)知道日期是来自文件还是在文件中,因此您可以简单地使用,这是一个特殊的宏month,可以为您处理日期格式和打印。daybiblatexdateyear.bib\printdate

编辑:已添加lawtitle到排序方案。

相关内容