[Tex/LaTex] BibTex custom bibliography order

bibliographiesbibtex

I need the bibliography in my tex file to be in a custom order. So far I've only found how to sort the bibliography alphabetically or in order of appearance. How may I sort it in a custom order?

Best Answer

You haven't provided a lot of specific information regarding the custom sorting principle(s) you wish to implement. The following solution is therefore necessarily of the bare-bones, no-frills variety.

  • You've indicated (I think) that you're OK with the way that the unsrt bibliography style formats various entries of type @article, @book, etc. I suggest you switch to the plain bibliography style. It applies the exact same formatting procedures as unsrt does; the main difference is that unsrt provides no sorting facility at all.

  • Insert the following instruction at the very top of your bib file:

    @preamble{ "\providecommand{\noopsort}[1]{} " }
    
  • Let's label the topics and associated groups of entries 01, 02, etc. It's important that they be given numeric labels. The assumption is that all entries labelled 01 should be listed before those with label 02, and so on.

    If you have more than 100 but fewer than 1000 groups, just switch the labelling system to 001, 002, etc.

  • For all entries that belong to topic 01, change the author field as follows: add the prefix \noopsort{01} to the surname of the first author in the author field. E.g., if the author field of a given entry that is supposed to belong to group 01 is given by

    author = "Author, Anna and Zebulon Zingales",
    

    change it to

    author = "\noopsort{01}Author, Anna and Zebulon Zingales",
    

    Note: no space between the prefix and the first author's surname.

  • Ditto for all remaining entries of type 01 and for all entries that belong to topics 02, 03, etc.

  • Since you're using a bibliography style that applies sorting, all entries whose first author's surname is prefixed with 01 will be placed before those with prefix 02 which, in turn, will precede those with prefix 03, etc. Here's why it's crucial to use numeric labels: in the ASCII table, the numerals 0 thru 9 occur before uppercase and lowercase letters. Thus, the numeric prefixes take precedence over the subsequent letters that make up the authors' names.

    For instance, the entry with author field "\noopsort{01}Author, Anna and Zebulon Zingales" will be placed before an entry with author field "\noopsort{02}Aardvark, Alison and Sean Sheep".

    A side effect, which is presumably not unwelcome, is that within each group/topic the entries will be sorted alphabetically. Finally, because \noopsort doesn't "do anything" with its argument as far as LaTeX is concerned, the labels won't show up in the typeset bibliography.

  • Then, rerun LaTeX -- you did change the argument of \bibliographystyle from unsrt to plain, right? -- BibTeX, and LaTeX twice more.