8

In biblatex version 2.5, bibliographic entries with the YEAR field in brackets in the .bib source were still sorted in the bibliography as if the field was without brackets. Cf. the example below:

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear]{biblatex}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1972,
    AUTHOR = "John Lennon",
    TITLE = "Peace on earth",
    YEAR = "1972",
    LOCATION = "London",
    PUBLISHER = "Music Press"}
@BOOK{lennon1974,
    AUTHOR = "John Lennon",
    TITLE = "More peace on earth",
    YEAR = "[1974]",
    LOCATION = "London",
    PUBLISHER = "Music Press"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{lennon1972}\nocite{lennon1974}
\printbibliography
\end{document}

enter image description here

This is no longer the case with biblatex version 2.7. I don't know what determines their sorting anymore, but it seems like the entries with the YEAR field in brackets is always put first in the sorted list under that author.

enter image description here

What can I do to get the sorting behavior of biblatex version 2.5 back?

Sverre
  • 20,729

1 Answers1

8

It will sort according to the value of the field so biblatex 2.5 was incorrect in this case. It's rather strange to put the brackets in the field - that's a style issue which is better handled by some other field which shows that the year needs special formatting. If you really must do it this way, do it automatically with:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=year,
            match=\regexp{\A\[(.+)\]\z},
            final]
      \step[fieldset=sortyear, fieldvalue={$1}]
    }
  }
}

This automatically adds a sortyear field consisting of only the numeric contnents of the year field if the year field has literal brackets in the .bib. Since in the default biblatex sorting schemes, sortyear is used instead of year for sorting, this will get the sorting right without changing the year field.

PLK
  • 22,776
  • Could you please clarify a couple of things for me? (1) biblatex 2.7 sorts based on the character [? What did version 2.5 do? (2) What is the "it" that your suggestion command does? Or in other words, could you clarify with some prose what the command does? – Sverre Aug 03 '13 at 12:01
  • 1
    I've added prose about what this does. I'd have to go back to the 2.5 code (well, actually the biber 1.5 code as biber does the sorting) to see what was happening but there have been some fairly substantial relevant internal changes in 2.6/1.6 to do with label* date fields. Biblatex shouldn't be auto-correcting sorting like you mention - that's too confusing in the long term. I suspect the behaviour you saw in 2.5 was an artefact and wasn't doing quite what you saw in general. – PLK Aug 03 '13 at 12:36
  • I get this error when adding your command: Runaway argument? { \maps [datatype=bibtex]{ \map { \step [fieldsource=year, match=\regexp \ETC. ! File ended while scanning use of \DeclareSourcemap. It seemed like it lacked a final }, but adding that resulted in a Missing \begin{document} error. – Sverre Aug 03 '13 at 13:10
  • Sorry, there was another typo in the example - corrected now. – PLK Aug 03 '13 at 19:29
  • I get this error now: ! LaTeX Error: Missing \begin{document}. – Sverre Aug 04 '13 at 13:06
  • Are you sure? Cut and pasting your MWE and the corrected code above works fine for me. – PLK Aug 04 '13 at 20:52
  • Sorry, I had forgotten to remove the previous command with the typo from further down my preamble. It works. – Sverre Aug 05 '13 at 11:20