如何在使用 biblatex/biber 时调整自定义类型 `@standard` 的排序

如何在使用 biblatex/biber 时调整自定义类型 `@standard` 的排序

在我的参考书目中,我有一些标准,我修改了给出的声明这里根据建议的引用方式这里(抱歉,该网站没有提供英文版本)。

现在的问题是,参考书目中的条目在默认nty样式中排序错误,因为作者总是相同的,接下来是标题(如下图所示,这是给定代码的结果)。

所以问题是,我如何才能说服biblatex/biber对条目进行正确的排序,即它们必须按照字段进行排序number


到目前为止,我发现我可以使用\DeclareSortingScheme(灵感来自这个答案),但我还没有发现是否有可能仅将其应用于指定的entrytypes。

entrytype我发现,使用命令可以删除指定 s 的排序字段\DeclareSortExclusion。将此与扩展版本相结合\DeclareSortingScheme{nty}{...}可得到所需的结果(请查看之前代码的注释部分\begin{document})。

但也许有更优雅的方法来实现期望的结果?

\begin{filecontents}{test1.bib}
@STANDARD{ISO2240,
  author       = {{International Organization for Standardization}},
  title        = {Photography -- Colour reversal camera films -- Determination
                  of ISO speed},
  year         = {2003},
  number       = {ISO 2240:2003-10},
  langid       = {english},
}
@STANDARD{ISO9660,
  author       = {{International Organization for Standardization}},
  title        = {Information processing; volume and file structure of CD-ROM
                  for information interchange},
  year         = {1988},
  number       = {ISO 9660:1988-04},
  langid       = {english},
}
\end{filecontents}
\documentclass{article}
\usepackage[
    style=numeric,
%    sorting=nty,   <-- default
        ]{biblatex}
    \addbibresource{test1.bib}
% -------------------------------------------------------------------------------------------------
%%% define own style for standards
%%% at <https://tex.stackexchange.com/questions/65637/how-to-cite-a-standard-iso-etc-in-biblatex>
%% it was given as ...
%\DeclareDatamodelEntrytypes{standard}
%\DeclareDatamodelEntryfields[standard]{type,number}
%\DeclareBibliographyDriver{standard}{%
%  \usebibmacro{bibindex}%
%  \usebibmacro{begentry}%
%  \usebibmacro{author}%
%  \setunit{\labelnamepunct}\newblock
%  \usebibmacro{title}%
%  \newunit\newblock
%  \printfield{number}%
%  \setunit{\addspace}\newblock
%  \printfield[parens]{type}%
%  \newunit\newblock
%  \usebibmacro{location+date}%
%  \newunit\newblock
%  \iftoggle{bbx:url}
%    {\usebibmacro{url+urldate}}
%    {}%
%  \newunit\newblock
%  \usebibmacro{addendum+pubstate}%
%  \setunit{\bibpagerefpunct}\newblock
%  \usebibmacro{pageref}%
%  \newunit\newblock
%  \usebibmacro{related}%
%  \usebibmacro{finentry}
%}
% ... but according to <http://www.beuth.de/de/hilfe/hilfezitierenvonnormen>
% much less fields are required
\DeclareDatamodelEntrytypes{standard}
\DeclareDatamodelEntryfields[standard]{type,number}
\DeclareBibliographyDriver{standard}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{number}%
  \setunit{\addspace}\newblock
  \printfield[parens]{type}%
  \newunit\newblock
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}
  \usebibmacro{finentry}
}

%% unfortunately then the entries are not sorted as one likes, because they are
%% sorted as "nty", so after "author, title, year" and not after the `number'
%% field
%% (have a look at section 4.5.5 "Sorting" (on page 183 of v3.4 of the manual))
%
%% this is the way how they should be sorted
%\DeclareSortingScheme{sortStandard}{
%    \sort{
%        \field{presort}
%    }
%    \sort[final]{
%        \field{sortkey}
%    }
%    \sort{
%        \field{number}
%    }
%    \sort{
%        \field{sorttitle}
%        \field{title}
%    }
%}
%% ----- uncomment the following block which brings up the desired result -----
% but because there seems to be no way of applying this scheme to an `entrytype'
% the "standard" `nty' sorting scheme has to be modified and the fields which
% should not be used for `@standard' are excluded from sorting
%\DeclareSortingScheme{nty}{
%    \sort{
%        \field{presort}
%    }
%    \sort[final]{
%        \field{sortkey}
%    }
%    \sort{
%        \field{sortname}
%        \field{author}
%        \field{editor}
%        \field{translator}
%        \field{sorttitle}
%        \field{title}
%        % ----- addition(s) -----
%        \field{number}
%        % ---------------------
%    }
%    \sort{
%        \field{sorttitle}
%        \field{title}
%    }
%    \sort{
%        \field{sortyear}
%        \field{year}
%    }
%}
%\DeclareSortExclusion{standard}{
%    sortname,
%    author,
%    editor,
%    translator,
%    sorttitle,
%    title,
%    sortyear,
%    year,
%}
%% ----------------------------------------------------------------------------
\begin{document}
    \cite{ISO2240,ISO9660}
    \printbibliography
\end{document}

该图显示了上述代码的结果

答案1

我认为你做的事情一点也不坏。如果它能带来预期的结果,你还要求什么呢?

因为答案只说明这一点有点牵强,所以我提供了一个替代解决方案。如果添加以下源映射,则可以使用常规排序方案

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{standard}
      \step[fieldsource=number, final]
      \step[fieldset=sortkey, origfieldval]
    }
  }
}

它只是将number字段(您想要排序的字段)复制到在sortkey其他字段之前考虑的字段。

相关内容