2

In the following MWE, I expect reference "B" to appear before "A" in the reference list, because sortyear should take priority over year. But I can't get that to happen after much tinkering... I've read this and this questions and the corresponding section of biblatex manual without much help.

\documentclass{article}
\usepackage[
  backend=bibtex,
  defernumbers=true,
  sorting=xxx,
]{biblatex}
\begin{filecontents}[overwrite]{mwe.bib}
  @article{A,
    title = {A},
    year = {1111},
    sortyear = {2222}
  }
  @article{B,
    title = {B},
    year = {2222},
    sortyear = {1111}
  }
\end{filecontents}
\addbibresource{mwe}\nocite{*}
\DeclareSortingTemplate{xxx}{
  \sort{
    \field{sortyear}
    \field{year}
  }
}
\begin{document}
  \printbibliography[resetnumbers=true]
\end{document}

jessexknight
  • 2,732
  • PS: I'm fully cleaning .aux etc. files between every compile. – jessexknight Apr 25 '22 at 17:25
  • If I change backend to biber and add the .bib extension to \addbibresource it does produce expected results for me. – gusbrs Apr 25 '22 at 17:47
  • Thanks. Me too. Is bibtex incompatible with \DeclareSortingTemplate? I need other features of bibtex... – jessexknight Apr 25 '22 at 17:49
  • I don't really know, but it appears so... What the manual says about this is that for the bibtex backend: "Sorting is global and is limited to us-ascii ordering". Which doesn't say anything about sorting templates. – gusbrs Apr 25 '22 at 17:55
  • Huh, thanks for that. I was actually able to switch to biber for now. – jessexknight Apr 25 '22 at 18:01

1 Answers1

6

As discussed in the comments, with backend=bibtex you can only use a restricted list of sorting schemes (none, nty, nyt, nyvt, anyt, anyvt, ynt, ydnt, debug) and \DeclareSortingTemplate is not available at all with BibTeX.

You will need to use Biber with your document. (Which is a good idea anyway since many of biblatex's advanced features require Biber. The documentation used to explain which bits were Biber-only, but a few years ago it was decided to make BibTeX a "legacy backend" and just assume that the average user uses Biber.)

https://github.com/plk/biblatex/commit/0c21cd8c142d1a2f0c2d1e4810890388fa82551e will give a warning in case unsupported sorting templates are used with BibTeX.

moewe
  • 175,683