8

I want to obtain different reference lists with reverse numbering order with prefix on the numbers, such as:

Books

[B3] Author, A., "Title1", 2016

[B2] Author, B., "Title2", 2016

[B1] Author, C., "Title3", 2015

Journals

[J2] Author, D., "Title4", 2016

[J1] Author, E., "Title5", 2014

and so on.

I had the following code that worked:

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{hyperref}

\usepackage[
    backend=bibtex, 
    style=numeric,
    firstinits=true,
    maxcitenames=99,
    maxbibnames=99,
    sorting=ydnt,
    defernumbers=true,
    isbn=false,
]{biblatex}
\addbibresource{publications.bib}

% Definition of asterisk
\newtoggle{bib@asterisk}
\DeclareEntryOption{asterisk}[true]{\settoggle{bib@asterisk}{#1}}

% Reverse ordering for numbers
\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%
  \iftoggle{bib@asterisk}%
    {\textbf{*}}%
    {}%
  }

\begin{document}

\nocite{*}
\printbibliography[title={Books},type=books,prefixnumbers={B}]
\printbibliography[title={Journals},type=article,prefixnumbers={J}]
\end{document}

After the last update of biblatex, I have troubles in replicating the same result that I had. Apparently prefixnumbers are deprecated, and they are enforcing me to use biber instead of bibtex.

The new code looks like this:

\documentclass{article}

\usepackage[
    backend=biber, 
    style=numeric,
    firstinits=true,
    maxcitenames=99,
    maxbibnames=99,
    sorting=ydnt,
    defernumbers=true,
    isbn=false,
]{biblatex}
\addbibresource{publications.bib}

\AtDataInput{%
  \xifinlistcs{\thefield{entrykey}}{entrylist:\therefsection}{}{%
    \listcsxadd{entrylist:\therefsection}{\thefield{entrykey}}%
    \csnumgdef{entrycount:\therefsection}{%
      \csuse{entrycount:\therefsection}+1}}}

% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}    
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}

\begin{document}
\nocite{*}

\newrefcontext[labelprefix=B]
\printbibliography[type=book,resetnumbers]

\newrefcontext[labelprefix=J]
\printbibliography[type=article,resetnumbers]

\end{document}

but what I get instead is something like

Books

[B5] Author, A., "Title1", 2016

[B4] Author, B., "Title2", 2016

[B3] Author, C., "Title3", 2015

Journals

[J5] Author, D., "Title4", 2016

[J4] Author, E., "Title5", 2014

Notice that I need also to cite the references, so I cannot use tricks like etaremune or similar. Do you have any idea how to solve this issue?

  • What is the purpose of such a numbering system? I can't see any value in it for the reader. – Ulrike Fischer Sep 12 '16 at 21:30
  • @UlrikeFischer I suppose it is for a CV or a list of publications. See also Biblatex descending order of references with labels not working – moewe Sep 13 '16 at 7:39
  • It is for CV/Publications list. I have found some solutions, but none of them is able to cite correctly the references. For example if you have: Books [B3] ... [B2] ... [B1] ... Journals [J2] ... [J1] ... and you want to cite them, with the regular \cite command, you get something like [J-3] [C-1]. – aps Sep 13 '16 at 8:59
  • @moewe thank you for the link, but it still does not solve the problem. I provided my solution that works with TeX Live 2016, but I still don't know how to solve the issue with the negative references whenever you try to cite the entries in a text. – aps Sep 13 '16 at 9:14
  • I didn't say it would solve your problem, it was just so the questions would appear linked in the sidebar. – moewe Sep 13 '16 at 9:15
3

Imho something like this could work: It counts the books and articles separatly.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[
    backend=biber,
    style=numeric,
    giveninits=true,
    maxcitenames=99,
    maxbibnames=99,
    sorting=ydnt,
    defernumbers=true,
    isbn=false,
]{biblatex}
\addbibresource{biblatex-examples.bib}


\AtDataInput[book]{%
 \xifinlistcs{\thefield{entrykey}}{entrylist:\therefsection}{}{%
  \listcsxadd{entrylist:\therefsection}{\thefield{entrykey}}%
  \csnumgdef{bookentrycount:\therefsection}{%
      \csuse{bookentrycount:\therefsection}+1}}}

\DeclareFieldFormat[book]{labelnumber}{\mkbibbookdesc{#1}}

\newrobustcmd*{\mkbibbookdesc}[1]{%
   B\number\numexpr\csuse{bookentrycount:\therefsection}+1-#1\relax}

\AtDataInput[article]{%
 \xifinlistcs{\thefield{entrykey}}{entrylist:\therefsection}{}{%
  \listcsxadd{entrylist:\therefsection}{\thefield{entrykey}}%
  \csnumgdef{articleentrycount:\therefsection}{%
      \csuse{articleentrycount:\therefsection}+1}}}

\DeclareFieldFormat[article]{labelnumber}{\mkbibarticledesc{#1}}

\newrobustcmd*{\mkbibarticledesc}[1]{%
   J\number\numexpr\csuse{articleentrycount:\therefsection}+1-#1\relax}

\begin{document}

\cite{iliad} \cite{aksin,herrmann}, \cite{augustine}, \cite{aristotle:anima}

\printbibliography[type=book,resetnumbers]

\printbibliography[type=article,resetnumbers]

\end{document}

enter image description here

Attention

This will not work if the bib has entries of type @set and one of the articles or books are part of this set. In this case the code will count the article but not show it in the bibliography.

  • Unfortunately, this is not working with TeXLive 2016. What I actually get is that only one element per type is shown in the references, plus, the references to the Journals (the one produced by the second \printbibliography) is always zero when cited in the text. I don't know why. – aps Sep 14 '16 at 18:47
  • My example works fine for me on a current texlive, and also on a current miktex which has already the next biblatex. If you did something different you should show it. – Ulrike Fischer Sep 14 '16 at 19:53
  • What is your current texlive? On Linux it works fine also for me, but the most up-to-date version of texlive on Linux is not the 2016 there, it is the 2015. The problem boils down to the version of biblatex, which from 3.3+ presents this problem. What is the version of that you are using? – aps Sep 16 '16 at 6:33
  • My "current texlive" is current. It is a texlive 2016 updated regularly. My miktex is up-to-date too. If you test the example make sure to delete the auxiliary files, sometimes some older labels survive in the aux-file. – Ulrike Fischer Sep 16 '16 at 7:01
  • Actually, now I managed to make it work. Thanks. However, I have another question. What if I want to filter out some of the entries, and separate them, like "submitted" and "accepted" papers, for example by means of writing \printbibliography[type=article,notkeyword=submitted,resetnumbers] and \printbibliography[type=article,keyword=submitted,resetnumbers] – aps Sep 16 '16 at 15:16
0

Combining the solutions here and here, we can use

\documentclass{article}

\usepackage[
    backend=biber,
    style=numeric,
    firstinits=true,
    maxcitenames=99,
    maxbibnames=99,
    sorting=ydnt,
    defernumbers=true,
    isbn=false,
]{biblatex}
\addbibresource{publications.bib}

% Reverse publication list numbering
% Count total number of entries in each refsection
\makeatletter
\defbibenvironment{counter}
  {\renewcommand{\blx@driver}[1]{}}
  {}
  {\csnumgdef{entrycount}{%
      \csuse{entrycount}+1}}
\makeatother

% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\csuse{entrycount}+1-#1\relax}


\begin{document}

\nocite{*}
\newrefcontext[labelprefix=B]
\printbibliography[env=counter,type=book,heading=none]
\printbibliography[type=book]

\csnumgdef{entrycount}{0}
\nocite{*}
\newrefcontext[labelprefix=J]
\printbibliography[env=counter,type=article,heading=none]
\printbibliography[type=article]
\end{document}

This should be flexible enough for you to use any other ways to classify all references, such as category, keyword, etc.

  • However, any citation in other places to these entries will be messed in some way. Help is welcome to fix citation. – xuhdev Dec 15 '17 at 7:47

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.