10

I'm trying to get a anti-chronological bibliography, that means I just want to appear the newest items at the top. After reading the the answer for this question I assumed, that the usage the sorting scheme ydnt and of sortyear (in the format 2012-1, 2012-2 and so on, where 2012-1 is older than 2012-2) should do that.

But it does not, it seems that only the first four digits of sortyear or the entry in year are used (which are in fact the same).

So, why that? And how could I get a new-to-old sorted bibliography without declaring a new sorting scheme? (Doing that I get the desired result.)

\documentclass{article}
\usepackage{filecontents}
\usepackage[english]{babel}
\usepackage[backend=biber,sorting=ydnt]{biblatex}

\begin{filecontents}{refs.bib}
@MISC{2012_1,
  author = {Me},
  title = {A Oldest, should be below},
  year = {2012},
  sortyear = {2012-1},
}
@MISC{2012_2,
  author = {Me},
  title = {C Second oldest, should be in middle},
  year = {2012},
  sortyear = {2012-2},
}

@MISC{2012_3,
  author = {Me},
  title = {B Newest, should be above},
  year = {2012},
  sortyear = {2012-3},
}
}\end{filecontents}

\addbibresource{refs.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

enter image description here

  • 2
    biblatex only uses the first four digits for the sortyear. Why? I assume it's because bibliographies never(?) need to such fine-grained detail. If I publish two articles in 2012, they only need to be sorted before 2011: no one cares if one was written in March and the other in September. However, if I absolutely needed to do this --- say for my own CV and I really want to do it ---, then why not simply use as sortyears the last four of your digits: 0121; 0122; 0123? They'll still show up as 2012 when printed.... – jon Oct 25 '13 at 5:46
  • 1
    Why don't you want to declare a sorting scheme that does what you want? Absent that, you will end up kludging around in the .bib file as Jon suggests. That will work, but it's bad practice. – Paul Stanley Oct 25 '13 at 9:40
9

Firstly, note that "2012-1" is not a valid ISO 8601 date format which biblatex expects in the date field. It's also not a valid year field for obvious reasons. This is why we still have the month field. So, to make this work, it's fairly easy. Change the format of your .bib entries to e.g:

@MISC{2012_1,
  author = {Me},
  title = {A Oldest, should be below},
  year = {2012},
  month = {1}
}
@MISC{2012_2,
  author = {Me},
  title = {C Second oldest, should be in middle},
  year = {2012},
  month = {2}
}

@MISC{2012_3,
  author = {Me},
  title = {B Newest, should be above},
  year = {2012},
  month = {3}
}

and then define a new "year month descending" sorting spec in your preamble. The name is arbitrary but call it say "ymdnt":

\DeclareSortingScheme{ymdnt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort[direction=descending]{
    \field[strside=left,strwidth=4]{sortyear}
    \field[strside=left,strwidth=4]{year}
    \literal{9999}
  }
  \sort[direction=descending]{
    \field{month}
    \literal{9999}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

This is just a copy of the "ydnt" scheme from biblatex.def with a sort on the month field added after year. Then load biblatex with sorting=ymdnt and it all works nicely.

  • Thanks for answer, which points me in the right direction. In fact, I just was wondering why the solution in the question linked above works with ynt, but not with ydnt. An the biblatex.def has the answer, because for the ynt sorting scheme there is no restriction to the first four digits (neither for sortyear nor for year), but for the ydnt sorting scheme there is (same as in the code you copied from there). – user38913 Oct 27 '13 at 7:22
  • How do you define this before biblatex is loaded? Alternatively, how do you pass this option to biblatex after it's already loaded? – Jonathan W. Oct 26 '17 at 3:40
  • 2
    Aha, if this goes after biblatex is loaded, then DeclareSortingScheme apparently doesn't just define the scheme but loads it too. Might be good to mention this in the answer. – Jonathan W. Oct 26 '17 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.