使用 Overleaf 的 \DeclareSortingTemplate

使用 Overleaf 的 \DeclareSortingTemplate

我需要将一个项目切换到 Overleaf。我正在使用biblatexBiber,并用它\DeclareSortingTemplate来创建一个单独的参考书目环境,该环境按速记而不是作者排序。

我是否需要特殊包裹或者......?

在我的常规设置中有效但在 Overleaf 上无效的最小示例:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}
\begin{filecontents}{example.bib}
@book{test,
  title      = {A Title},
  year       = {2420},
  author     = {Famous, Person},
  location      = {Big City},
  publisher  = {Fancy Academic Press},
  shorthand  = {b2420},
}
\end{filecontents}

\usepackage[backend=biber,style=authoryear]{biblatex}
\addbibresource{example.bib}

% special sort style
\DeclareSortingTemplate{byShorthand}{
  \sort{\field{shorthand}}
  \sort{\field{name}}
  \sort{\field{year}}
  \sort{\field{title}}
}

\begin{document}
I want to cite \cite{test}

\newrefcontext[sorting=byShorthand]
\printbibliography[title={Bibliography sorted by shorthand}]

\newrefcontext[sorting=nyt]
\printbibliography[title={Bibliography sorted by author}]
\end{document}

答案1

根据 Paul 的上述评论,我能够通过使用 (现已弃用) \DeclareSortingScheme(biblatex版本 <3.8) 而不是\DeclareSortingTemplate( biblatex>=3.8) 来解决此问题。截至本文发布时,Overleafbiblatex在新项目中使用 TeX Live 2017 和 3.7 (2016/12/05)。

工作示例:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}
\begin{filecontents}{example.bib}
@book{test,
  title      = {A Title},
  year       = {2420},
  author     = {Famous, Person},
  location      = {Big City},
  publisher  = {Fancy Academic Press},
  shorthand  = {b2420},
}
@book2{test2,
  title      = {A Title},
  year       = {2420},
  author     = {Author, Person},
  location      = {Big City},
  publisher  = {Fancy Academic Press},
  shorthand  = {c2420},
}
\end{filecontents}

\usepackage[backend=biber,style=authoryear]{biblatex}
\addbibresource{example.bib}

% special sort style
\DeclareSortingScheme{byShorthand}{
  \sort{\field{shorthand}}
  \sort{\field{name}}
  \sort{\field{year}}
  \sort{\field{title}}
}

\begin{document}
I want to cite \cite{test} and \cite{test2}

\newrefcontext[sorting=byShorthand]
\printbibliography[title={Bibliography sorted by shorthand}]

\newrefcontext[sorting=nyt]
\printbibliography[title={Bibliography sorted by author}]
\end{document}

编辑:此外,正如上面 moewe 指出的那样,我可以使用预定义的“sorting=shorthand”选项。这是一种更简洁的方法!

相关内容