按字母顺序对作者和组织进行排序

按字母顺序对作者和组织进行排序

如果我的条目只有一个组织,则按字母顺序排序不起作用。参考书目应按字母顺序排列,组织和作者之间应无等级划分。

我认为使用双括号括起来的公司作者的解决方案不起作用,因为我需要用斜体表示的组织。

\begin{filecontents}{\jobname.bib}
      @online{musk,
        author       = {Elon Musk},
        title        = {Tesla Model X},
        url          = {https://www.tesla.com/modelx?redirect=no},
        date         = {2017-07-04},
        organization = {Tesla},
        urldate      = {2018-10-16},
      },
    
 @online{b,
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {ABZ},
    urldate      = {2018-10-16},
},

 @online{a,
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {ZBA},
    urldate      = {2018-10-16},
},
\end{filecontents}

\documentclass{article}
\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\DeclareListFormat{organization}{%
  \usebibmacro{list:delim}{#1}%
  \mkbibemph{#1}\isdot
  \usebibmacro{list:andothers}}

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \printlist{organization}%
  \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
  \usebibmacro{date}%
  \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}}

\begin{document}
Let's cite! \footcite{musk} \footcite{a} \footcite{b}
\printbibliography
\end{document}

通过这个 MWE 我得到以下输出:enter image description here

但应按如下方式排序:

ABZ [...]
麝香 [...]
ZBA [...]

我怎样才能实现这个目标?

答案1

实际上,该organization字段不是默认排序模板的一部分。您可以添加它,或者,我建议您假设此类条目数量有限,您可以sortkey为感兴趣的 bib 条目提供一个:

\begin{filecontents}{\jobname.bib}
  @online{musk,
    author       = {Elon Musk},
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {Tesla},
    urldate      = {2018-10-16},
  },

  @online{b,
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {ABZ},
    sortkey      = {ABZ},
    urldate      = {2018-10-16},
  },

  @online{a,
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {ZBA},
    sortkey      = {ZBA},
    urldate      = {2018-10-16},
  },
\end{filecontents}

\documentclass{article}
\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\DeclareListFormat{organization}{%
  \usebibmacro{list:delim}{#1}%
  \mkbibemph{#1}\isdot
  \usebibmacro{list:andothers}}

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \printlist{organization}%
  \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
  \usebibmacro{date}%
  \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}}

\begin{document}
Let's cite! \footcite{musk} \footcite{a} \footcite{b}
\printbibliography
\end{document}

enter image description here

或者,按照评论中的要求,通过添加organization到排序模板:

\begin{filecontents}{\jobname.bib}
  @online{musk,
    author       = {Elon Musk},
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {Tesla},
    urldate      = {2018-10-16},
  },

  @online{b,
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {ABZ},
    urldate      = {2018-10-16},
  },

  @online{a,
    title        = {Tesla Model X},
    url          = {https://www.tesla.com/modelx?redirect=no},
    date         = {2017-07-04},
    organization = {ZBA},
    urldate      = {2018-10-16},
  },
\end{filecontents}

\documentclass{article}
\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}

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

\DeclareListFormat{organization}{%
  \usebibmacro{list:delim}{#1}%
  \mkbibemph{#1}\isdot
  \usebibmacro{list:andothers}}

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \printlist{organization}%
  \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
  \usebibmacro{date}%
  \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}}

\begin{document}
Let's cite! \footcite{musk} \footcite{a} \footcite{b}
\printbibliography
\end{document}

相关内容