# Multibib reverse label or sort order

I'm using multibib. I manually set the order of the bibliography. I would like the order of the numbered items to be reversed. For example, my document has:

\nociteX{Foo}
\nociteX{Bar}


And the document then shows:

[1] Foo
[2] Bar


I would like the document to show:

[2] Foo
[1] Bar


Can anyone explain what to change in my .bst file, or a flag to multibib that I am missing that will achieve this?

-
It might depend on your bibstyle, but changing ITERATE {call.type$} to REVERSE {call.type$} should invert the order of the entries. However, this will also reverse the numbering of the references. –  Olof Jan 27 '11 at 8:58
If you're willing to switch to biblatex, have a look at tex.stackexchange.com/questions/21401/…. –  lockstep Sep 18 '11 at 13:50
@mankoff: Have a look at the documentation. One possibility is to work with keywords. –  Marco Daniel Oct 22 '11 at 19:33
@mankoff A single bib file would need a different approach. It's possible - I just don't have time ATM to look into it. –  Audrey Nov 15 '11 at 18:19
@Audrey: I'd really like to see a biblatex solution! –  lockstep Dec 4 '11 at 13:54

The biblatex package offers features comparable to those of multibib. References from a single bib file can be subdivided using various options of \printbibliography. Examples include type, keyword and category. Refer to the biblatex manual for details. Prefixes to the labelnumber are specified with the prefixnumbers option.

Assuming each sub-bibliography has a unique prefix, descending label numbers can be obtained by altering the labelnumber field format so that it prints the value given by the total prefix-specific entry count, minus the actual labelnumber, plus one.

\documentclass{article}
\usepackage[style=numeric-comp,sorting=ydnt,defernumbers]{biblatex}

\AtDataInput{%
\csnumgdef{entrycount:\strfield{prefixnumber}}{%
\csuse{entrycount:\strfield{prefixnumber}}+1}}

\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\newrobustcmd*{\mkbibdesc}[1]{%
\number\numexpr\csuse{entrycount:\strfield{prefixnumber}}+1-#1\relax}

\begin{document}
Filler text \cite{aksin,bertram,angenendt}.
\printbibliography[prefixnumbers={P},type=inproceedings,title={Presentations},
\end{document}


This solution works with either backend, though with biber the "rerun LaTeX" messages in the log may not stabilize. In any case heed the warning; the first time the message disappears after recompiling should give the correct document.

-
Very nice, but when I try to also cite in the text, things seem a bit odd. I added this just after the \begin{document}: This is a test citation of \cite{aristotle:anima, knuth:ct} and \cite{ctan}. and it produced: This is a test citation of [P-2, K0] and [W0]. –  mankoff Dec 10 '11 at 23:37
@mankoff Thanks for mentioning this issue. The original solution only worked with \nocite. I've made edits to fix this. Anticipate weird results if your categories aren't mutually exclusive. –  Audrey Dec 11 '11 at 0:29
@Audrey It seems to me that this solution cannot work with separate \printbibliography commands; but as I read the code I think that a user-level command for this would be possible as well. Would that be too much work (probably in order to process all \printbibliography options)? Sorry, but my low-level (la)tex skills are non-existent. –  nplatis Feb 14 '12 at 14:57
@nplatis Considering this again, I can see now why a solution that doesn't extend \bibbycategory would be useful. You might want to add some text between the bibliographies, for example. If you haven't found a solution already, I can post one for your question when I find some time. The above solution and the one I have in mind for you won't work for sortcites=true/numeric-comp and mixed-category citation lists, however. –  Audrey Mar 21 '12 at 21:44
@Audrey Thanks for the reply. That is what I had in mind when asking for separate \printbibliography commands. I have not found a solution yet, but I have not researched it too much. –  nplatis Mar 22 '12 at 17:09

I have a possible answer (possible because my installation crashed before I can test all of the features). It is relying, as mentionned, on biblatex, with biber as a backend.

In the preamble, you mention that you want to use biber as a back end (useful for tweaking the sorting), that you want to use the new sorting scheme you devised, and that you are going to play with the prefix in the bibliography.

\usepackage[defernumbers=true,sorting=reverse,backend=biber]{biblatex}

\DeclareSortingScheme{reverse}{
\sort[direction=descending]{\citeorder}
}


At the end of the document, you are printing the different bibliographies with the help of keyword to differentiate between them.

\printbibliography[keyword=original,prefixnumbers=F,title=Original sources]

\printbibliography[keyword=known,prefixnumbers=B,title=Other sources]


I successfully managed to get the [F1], [F2] and then [B1] and [B2] behavior, but was not able to test the biber tweak due to crashing. However, I am fairly convinced that this is the way to go, due to previous experiments.

I am aware that this answer is not complete as it is not fully tested, but I wanted to launch it out so that people can play with it until I manage to repair my set-up (at work, where I have huge networking trouble, hence possible long duration before repair).

-
Did you have a chance to do any further testing? AFAIK this will give descending labelnumber to the citations, but prints the bibliography by ascending labelnumber. –  Audrey Dec 10 '11 at 21:57
I did not do any further testing yet. My config is still out and I can't use biber anymore at work. I could try at home, but I am finishing my thesis, and I don't want to jinx anything at this moment... –  Martigan Dec 13 '11 at 15:23
I've finally tested this implementation. It does not mimic the other answer. If the references are sorted newest-first (ascending?), then the numbers are 1..n (descending). Or vice-versa. This is a shame. This implementation is so much more compact than the other solution. –  mankoff Jul 6 '12 at 21:35