Biblatex:调整自定义类型的引用和排序

Biblatex:调整自定义类型的引用和排序

我尝试为 bib 文件定义一个新的 entrytype(主要受到如何调整自定义类型的排序;我也想为标准定义一个类型)。我的主要目标是在number字段中使用一个简单的数字,设置定义组织(目前,我使用一个新字段definedby,但如果能够重用该字段organization就更好了),并避免在其他字段中再次声明相同的信息。

就我目前的状态而言(见下面的示例),参考书目打印得很好(字母样式除外——在这种情况下,我无法在两个标签部分之间生成空格)。但我仍然有以下问题:

  • 条目按照我的字段排序definedby,但没有按照字段排序number。我以为将它们连接起来进行排序应该很容易,但似乎出了点问题。

  • 我想调整引用以仅使用字段definedby(或organization)和number,但仅针对这种新的条目类型,而不是针对每种类型(至少\cite\textcite应该可以工作,而不会干扰例如\citetitle)。

如果我使用该字段shorthand(参见示例中的注释行),并将该字段设置sortkey为相同的值,我就会得到我想要的行为。如果不设置这些字段并重复数据,是否可以获得相同的行为?

如有任何帮助或提示我们将不胜感激!

梅威瑟:

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelEntrytypes{standard}
\DeclareDatamodelFields[type=field, datatype=literal, label=true]{definedby}
\DeclareDatamodelEntryfields[standard]{
  title,
  definedby,
  day,
  month,
  year,
  endday,
  endmonth,
  endyear,
  addendum,
  author,
  doi,
  editor,
  editortype,
  howpublished,
  language,
  location,
  note,
  number,
  organization,
  pubstate,
  subtitle,
  titleaddon,
  type,
  url,
  urldate,
  urlday,
  urlmonth,
  urlyear,
  version}
\DeclareDatamodelConstraints[standard]{
    \constraint[type=mandatory]{
      \constraintfieldsxor{
        \constraintfield{date}
        \constraintfield{year}
      }
    }
  }
\DeclareDatamodelConstraints[standard]{
  \constraint[type=mandatory]{
    \constraintfield{title}
    \constraintfield{number}
    \constraintfield{definedby}
  }
}
\end{filecontents}
\begin{filecontents}{lit.bib}
@standard{DIN:222,
  shorthand =  {DIN EN 222},
  definedby =  {DIN EN},
  number =     222,
  month =      mar,
  year =       {2002},
  title =      {Another standard with a long, unwiedly title that should not
    be used by cite in any way}
}
@standard{DIN:111,
  shorthand = {DIN EN 111},
  definedby =  {DIN EN},
  number =     111,
  month =      apr,
  year =       {2001},
  title =      {Title of some standard that is quite long and should not be used
    by cite, because we want the number as a simple, short reference}
}
@standard{DIN:min,
  definedby =    {DIN EN},
  number =       4711,
  title =        {Simple title of some standard},
}
\end{filecontents}
%
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[backend=biber,style=authoryear]{biblatex}

\newbibmacro*{definedby+number}{%
  \printfield{definedby}%
  \setunit{\addnbspace}%
  \printfield{number}}

\DeclareBibliographyDriver{standard}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \iffieldundef{labelalpha}{%
    \usebibmacro{definedby+number}%
  }{}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \printfield{howpublished}%
  \newunit\newblock
  \printfield{type}
  \newunit
  \printfield{version}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \printdate%
  \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}}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{standard}
      \step[fieldset=type, fieldvalue=Norm]
    }
    \map[overwrite=false]{
      \pertype{standard}
      \step[fieldsource=definedby]
      \step[fieldset=sortkey, origfieldval, final]
      \step[fieldsource=number]
      \step[fieldset=sortkey, origfieldval, append]
    }
  }
}

\DeclareLabelalphaTemplate[standard]{
  \labelelement{
    \field[final]{shorthand}
    \field{definedby}}
  \labelelement{\addspace}%% seems not to work
  \labelelement{\field{number}}}

\addbibresource{lit.bib}
\begin{document}
\cite{DIN:222}
\nocite{*}
\printbibliography
\end{document}

相关内容