1

I have a number of articles wit same author and year. In my latex document, some citation keys are changed from the original ones in Zotero. This is quite annoying, since the article then are presented in the wrong order in the bibliography. For example:

Zotero: 1. article = bahn2017a 2. article = bahn2017b 3. article = bahn2017c 4. article = bahn2017d

Latex: 1. article = bahn2017a 2. article = bahn2017d 3. article = bahn2017b 4. article = bahn2017c

What is really strange is that when I make a citation in the text with e.g. textcite, the list of entries in my .bib-file has the articles in the right order and with the correct citation keys from Zotero. So, I guess it must be biblatex which changes the citation keys. But why would it do that, and more importantly: how do I force biblatex to use the original order?

 \documentclass{report}
\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}

\usepackage[backend=biber,maxbibnames=99,urldate=short,sortlocale=danish,firstinits=true,style=authoryear-icomp,dashed=false,doi=false,isbn=false,url=true,]{biblatex}

\addbibresource{\jobname.bib}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{bahn2017c,
    title = {Evolution of Teachers' Anticipation of Didactical Situations in the Course of Three Lesson Studies},
    journaltitle = {Annales de Didactique et de Sciences Cognitives},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/Y3G88PIA/Bahn - 2017 - Evolution of teachers' anticipation of didactical .pdf},
    pubstate = {submitted}
}
@inproceedings{bahn2017d,
    location = {{Nagoya, Japan}},
    title = {How Infrastructures of Lesson Studies Impact on Teachers' Learning},
    eventtitle = {{{WALS International Conference}}, {{November}} 24-26, 2017},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/MVURD5TC/wals-pres.pdf},
    pubstate = {submitted}
}
@article{bahn2017a,
    title = {An Experiment with {{Open}}-Ended {{Approach}} in Grade Four Probability Teaching},
    journaltitle = {Recherches en Didactique des Mathématiques},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/LN55IYG2/Bahn - 2017 - An experiment with Open-ended Approach in grade fo.pdf},
    pubstate = {submitted}
}
@article{bahn2017b,
    title = {Teachers Learning from Their First Lesson Study},
    journaltitle = {Journal of Mathematics Teacher Education},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/3H3WVRMA/Bahn - 2017 - Teachers learning from their first lesson study.pdf},
    pubstate = {submitted}
}

\end{filecontents}

\begin{document}
\chapter{List of papers and abstracts}
\noindent \fullcite{bahn2017a}.\\

\bigskip \noindent \fullcite{bahn2017b}.\\

\bigskip \noindent \fullcite{bahn2017c}.\\

\bigskip \noindent \fullcite{bahn2017d}.\\

\section{References}
\sloppy
\printbibliography[heading=none]
\end{document}
17
  • 2
    Could you please turn your code snippet into a compilable MWEB with the four entries you mention in your question?
    – leandriis
    Dec 30, 2017 at 11:45
  • 4
    the actual name of the keys and the order of bib entries are irrelevant, you could also use "blub2017" or "holzeisenbahn" as key, biblatex/biber will create the keys and the order according to your settings. Dec 30, 2017 at 11:53
  • 4
    Sorting in biblatex is set using the sorting package option. The default is nyt (name, year, title) for authoryear styles. biblatex creates the extra date parts (a, b, c, d) based on this. You can manually modify the sorting order using the sortkey, sortname, and sorttitle fields. What is the logic behind the sort order you want? Having them sorted by title in the bibliography seems pretty reasonable to me. Dec 30, 2017 at 12:22
  • 4
    That makes sense, but you haven't given a more precise date to biblatex than just the year. How can it know which one comes first? As Ulrike mentioned, biblatex does not consider the entry key when it sorts, it uses the field data. biblatex isn't changing citation keys, it's just not even using them. There are ways to solve your problem though. I'll post an answer. Dec 30, 2017 at 14:01
  • 1
    As I already wrote: the key names are irrelevant. You can use what you want in the bib-file. Dec 30, 2017 at 14:01

3 Answers 3

3

My impression is that the first of David's advices -- that is, to use sortyear -- is the soundest. But your requirement of not being able to add custom fields due to the use of Zotero indeed complicates things. Btw, you might want to consider a more flexible alternative, such as JabRef (see LaTeX and bibliography management tools).

Still, there is a way to change your data dynamically, with biblatex's DeclareSourcemap. In your case, you could use:

\DeclareSourcemap{
    \maps[datatype=bibtex]{
        \map{
            \step[fieldsource=entrykey, match=bahn2017a, fieldset=sortyear, fieldvalue=2017a]
            \step[fieldsource=entrykey, match=bahn2017b, fieldset=sortyear, fieldvalue=2017b]
            \step[fieldsource=entrykey, match=bahn2017c, fieldset=sortyear, fieldvalue=2017c]
            \step[fieldsource=entrykey, match=bahn2017d, fieldset=sortyear, fieldvalue=2017d]
        }
    }
}

Essentially, this implements the first of David's alternatives, without directly editing your bib file.

A MWE:

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}

\usepackage[backend=biber,maxbibnames=99,urldate=short,sortlocale=danish,giveninits=true,style=authoryear-icomp,dashed=false,doi=false,isbn=false,url=true,]{biblatex}

\addbibresource{\jobname.bib}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{bahn2017c,
    title = {Evolution of Teachers' Anticipation of Didactical Situations in the Course of Three Lesson Studies},
    journaltitle = {Annales de Didactique et de Sciences Cognitives},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/Y3G88PIA/Bahn - 2017 - Evolution of teachers' anticipation of didactical .pdf},
    pubstate = {submitted}
}
@inproceedings{bahn2017d,
    location = {{Nagoya, Japan}},
    title = {How Infrastructures of Lesson Studies Impact on Teachers' Learning},
    eventtitle = {{{WALS International Conference}}, {{November}} 24-26, 2017},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/MVURD5TC/wals-pres.pdf},
    pubstate = {submitted}
}
@article{bahn2017a,
    title = {An Experiment with {{Open}}-Ended {{Approach}} in Grade Four Probability Teaching},
    journaltitle = {Recherches en Didactique des Mathématiques},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/LN55IYG2/Bahn - 2017 - An experiment with Open-ended Approach in grade fo.pdf},
    pubstate = {submitted}
}
@article{bahn2017b,
    title = {Teachers Learning from Their First Lesson Study},
    journaltitle = {Journal of Mathematics Teacher Education},
    date = {2017},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/3H3WVRMA/Bahn - 2017 - Teachers learning from their first lesson study.pdf},
    pubstate = {submitted}
}

\end{filecontents}

\DeclareSourcemap{
    \maps[datatype=bibtex]{
        \map{
            \step[fieldsource=entrykey, match=bahn2017a, fieldset=sortyear, fieldvalue=2017a]
            \step[fieldsource=entrykey, match=bahn2017b, fieldset=sortyear, fieldvalue=2017b]
            \step[fieldsource=entrykey, match=bahn2017c, fieldset=sortyear, fieldvalue=2017c]
            \step[fieldsource=entrykey, match=bahn2017d, fieldset=sortyear, fieldvalue=2017d]
        }
    }
}


\begin{document}
\noindent \fullcite{bahn2017a}.\\

\bigskip \noindent \fullcite{bahn2017b}.\\

\bigskip \noindent \fullcite{bahn2017c}.\\

\bigskip \noindent \fullcite{bahn2017d}.\\

\section{References}
\sloppy
\printbibliography[heading=none]
\end{document}

enter image description here

6
  • @DavidPurton, an extension of your first suggestion.
    – gusbrs
    Dec 30, 2017 at 16:34
  • that is a super solution which has solved my present problem. To make it ultra-super-fantastic-awesome, is there anyway the fieldvalue can be generated based in date automatically?
    – jbahn
    Dec 30, 2017 at 17:21
  • 1
    @jbahn, I think this approach is interesting if you'd like to set the sort order of some of your entries manually. If you'd like to sort them by date automatically, I'd recommend you David's third alternative.
    – gusbrs
    Dec 30, 2017 at 18:07
  • You are right. Actually David tried to help me out on that solution but it doesn't work for me - though it works fine on his side. We suspect tat my TexLive is of a too old version. I will update and try later, but I can take no change now, as I am submitting my Ph.D. thesis tomorrow (can't afford no technical scr*w ups!). Thanks for your time and functional suggestion.
    – jbahn
    Dec 30, 2017 at 18:29
  • It's possible to add fields to the Zotero bibtex exports using the BBT plugin (full disclosure: I'm the author of the plugin)
    – retorquere
    Feb 18, 2018 at 0:16
3

I suggest you add a sortyear field to your entries.

Something like this (BTW, you should use giveninits not firstinits:

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}

\usepackage[backend=biber,maxbibnames=99,urldate=short,sortlocale=danish,giveninits=true,style=authoryear-icomp,dashed=false,doi=false,isbn=false,url=true,]{biblatex}

\addbibresource{\jobname.bib}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{bahn2017c,
    title = {Evolution of Teachers' Anticipation of Didactical Situations in the Course of Three Lesson Studies},
    journaltitle = {Annales de Didactique et de Sciences Cognitives},
    date = {2017},
    sortyear = {2017c},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/Y3G88PIA/Bahn - 2017 - Evolution of teachers' anticipation of didactical .pdf},
    pubstate = {submitted}
}
@inproceedings{bahn2017d,
    location = {{Nagoya, Japan}},
    title = {How Infrastructures of Lesson Studies Impact on Teachers' Learning},
    eventtitle = {{{WALS International Conference}}, {{November}} 24-26, 2017},
    date = {2017},
    sortyear = {2017d},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/MVURD5TC/wals-pres.pdf},
    pubstate = {submitted}
}
@article{bahn2017a,
    title = {An Experiment with {{Open}}-Ended {{Approach}} in Grade Four Probability Teaching},
    journaltitle = {Recherches en Didactique des Mathématiques},
    date = {2017},
    sortyear = {2017a},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/LN55IYG2/Bahn - 2017 - An experiment with Open-ended Approach in grade fo.pdf},
    pubstate = {submitted}
}
@article{bahn2017b,
    title = {Teachers Learning from Their First Lesson Study},
    journaltitle = {Journal of Mathematics Teacher Education},
    date = {2017},
    sortyear = {2017b},
    author = {Bahn, Jacob},
    file = {/home/jb/.mozilla/firefox/mwad0hks.default/zotero/storage/3H3WVRMA/Bahn - 2017 - Teachers learning from their first lesson study.pdf},
    pubstate = {submitted}
}

\end{filecontents}

\begin{document}
\noindent \fullcite{bahn2017a}.\\

\bigskip \noindent \fullcite{bahn2017b}.\\

\bigskip \noindent \fullcite{bahn2017c}.\\

\bigskip \noindent \fullcite{bahn2017d}.\\

\section{References}
\sloppy
\printbibliography[heading=none]
\end{document}

enter image description here


Second Way

If you want to sort using your entry key (which I don't recommend), you need to add a couple of blocks.

Add this just before \begin{document}:

\DeclareSortingTemplate{nkyt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{entrykey}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
}

And add this just after \begin{document}

\newrefcontext[sorting=nkyt]

Output is the same as above and you don't need the sortyear fields.


Third Way

Add the option date=year to your biblatex options.

Supply full dates for your articles in the format date = {yyyy-mm-dd}.

Add this just before \begin{document}:

\DeclareSortingTemplate{nyt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{month}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
}

This is probably the best solution I think actually.

1
  • I think likewise, that the third option is meeting the requirements of the question the best without completely taking sorting away from the machine, which usually does the job quite well.
    – thymaro
    Dec 30, 2017 at 16:59
2

This is possible to do without leaving Zotero. Mind that the following will affect all your BBT-driven biblatex exports from Zotero, so I wouldn't recommend keeping this in place. But if this is what you want to do:

  1. Install the BBT plugin in Zotero (full disclosure: I am the author of the plugin) if you don't have it already; if you use Zotero and your keys look like "bahn2017b", you are most likely already using it
  2. Go into the BBT preferences and install the following postscript

    if (Translator.BetterBibLaTeX) this.add({name: 'sortname', value: item.date, enc: 'date' })

This will set add a field called "sortname" to every reference but with the value set to the full date of the reference. Since the default sort is "nyt", this will sort your references by the full date to any precision you've specified in the date field in Zotero.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .