如何使用 sorting=none 根据日期对单个引用命令的多个键进行排序

如何使用 sorting=none 根据日期对单个引用命令的多个键进行排序

我使用biblatex样式numeric-compsorting=none选项。因此,参考文献的显示顺序与引用顺序相同。但是,当我同时引用多个出版物时,\cite{key1,key2,key3}我希望它们按照出版日期排序(最早的在前)。biblatex具有sortcites由 开启的选项numeric-comp,原则上可对具有多个键的引用进行排序,但被全局 抵消sorting=none。如何仅在多键引用中指定排序选项?

\documentclass{article}

\usepackage[style=numeric-comp]{biblatex}
\ExecuteBibliographyOptions{
  sorting=none,
% sortcites % activated by numeric-comp
}

\begin{filecontents}{\jobname.bib}
@misc{key0,
  author   = {Unrelated},
  title    = {Before},
  year     = {2010},
}
@misc{key1,
  author   = {Young},
  title    = {Third},
  year     = {2020},
  addendum = {should be [4]},
}
@misc{key2,
  author   = {Middle},
  title    = {Second},
  year     = {2010},
  addendum = {should be [3]},
}
@misc{key3,
  author   = {Old},
  title    = {First},
  year     = {2000},
  addendum = {should be [2]},
}
@misc{key4,
  author   = {Unrelated},
  title    = {After},
  year     = {2010},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
Unrelated before \cite{key0}.
Discovered by \cite{key1,key2,key3}.
Unrelated after \cite{key4}.
\printbibliography
\end{document}

答案1

这是对您发布的 MWE 有用的东西,但我不确定它是否足以满足您的实际文档的要求。

定义一个排序方案就足够了,该方案主要按引用顺序排序,但按ynt排序顺序打破平局。由于在同一篇论文中引用的引用都\cite具有相同的引用顺序,因此在这种情况下似乎会产生预期的结果。

\documentclass{article}

\usepackage[sortcites=true,style=numeric-comp]{biblatex}
\usepackage{hyperref}

\DeclareSortingTemplate{none-ynt}{
  \sort{\citeorder}
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortyear}
    \field{year}
    \literal{9999}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

\ExecuteBibliographyOptions{sorting=none-ynt}

\begin{filecontents}{\jobname.bib}
@misc{key0,
  author   = {Unrelated},
  title    = {Before},
  year     = {2010},
}
@misc{key1,
  author   = {Young},
  title    = {Third},
  year     = {2020},
  addendum = {should be [4]},
}
@misc{key2,
  author   = {Middle},
  title    = {Second},
  year     = {2010},
  addendum = {should be [3]},
}
@misc{key3,
  author   = {Old},
  title    = {First},
  year     = {2000},
  addendum = {should be [2]},
}
@misc{key4,
  author   = {Unrelated},
  title    = {After},
  year     = {2010},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
Unrelated before \cite{key0}.
Discovered by \cite{key1,key3,key2}.
Unrelated after \cite{key4}.
\printbibliography
\end{document}

[1] 之前不相关。[2–4] 发现。[5] 之后不相关。

答案2

sortcites表示\cite{}根据当前活动的参考上下文排序。因此,如果您希望对引用进行标准日期排序并对参考书目进行引用顺序排序:

\documentclass{article}

\usepackage[sortcites=true,sorting=ynt,style=numeric-comp]{biblatex}
\begin{filecontents}{\jobname.bib}
@misc{key0,
  author   = {Unrelated},
  title    = {Before},
  year     = {2010},
}
@misc{key1,
  author   = {Young},
  title    = {Third},
  year     = {2020},
  addendum = {should be [4]},
}
@misc{key2,
  author   = {Middle},
  title    = {Second},
  year     = {2010},
  addendum = {should be [3]},
}
@misc{key3,
  author   = {Old},
  title    = {First},
  year     = {2000},
  addendum = {should be [2]},
}
@misc{key4,
  author   = {Unrelated},
  title    = {After},
  year     = {2010},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
Unrelated before \cite{key0}.
Discovered by \cite{key1,key2,key3}.
Unrelated after \cite{key4}.
\newrefcontext[sorting=none]
\printbibliography
\end{document}


相关内容