[Tex/LaTex] Biblatex descending order of references with labels not working

biblatexsorting

I just downloaded TeX Live 2016 and it broke my CV which had my publications (single .bib file) divided by type. It used to print

Refereed Conference Publications
[C1]

Miscellaneous
[M5]
[M4]
[M3]
[M2]
[M1]

However after the update, the numbering was all over the place. Something like

Refereed Conference Publications
[C3]

Miscellaneous
[M13]
[M12]
[M11]
[M10]
[M9]

I was looking online and saw that they changed how \printbibliography works. Now, we are not allowed to put the prefixnumber as an option.

After looking in this site, I found this question and answer. This works for me now, but I am not able to print the labels, i.e.

Refereed Conference Publications
[1]

Miscellaneous
[5]
[4]
[3]
[2]
[1]

Is there a way to make it work with the labels?

Thanks!

EDIT 1: Here is a MWE

%% pdflatex MWE
%% biber MWE
%% pdflatex MWE
%% pdflatex MWE
\documentclass[11pt,letterpaper,roman]{moderncv}       

\moderncvstyle{classic}
\moderncvcolor{blue} 
\renewcommand{\rmdefault}{ppl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[scale=0.8]{geometry}
\setlength{\hintscolumnwidth}{2.5cm}

\name{Miguel}{Velez}

\usepackage[defernumbers=true,sorting=none,backend=biber,style=numeric]{biblatex}

\AtDataInput{%
  \csnumgdef{entrycount:\therefsection:\thefield{entrytype}}{%
    \csuse{entrycount:\therefsection:\thefield{entrytype}}+1}}

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

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{% label format from numeric.bbx
        \printfield{labelprefix}%
        \printfield{labelnumber}}}
     {\setlength{\topsep}{0pt}% layout parameters from moderncvstyleclassic.sty
      \setlength{\labelwidth}{\hintscolumnwidth}%
      \setlength{\labelsep}{\separatorcolumnwidth}%
      \leftmargin\labelwidth%
      \advance\leftmargin\labelsep}%
      \sloppy\clubpenalty4000\widowpenalty4000}
  {\endlist}
  {\item}  

\addbibresource{bibliography.bib}  

\begin{document}
\makecvtitle

\section{Publications}
%\newrefcontext[labelprefix=C]
\nocite{WLS:ICSE76}%,VS:IUST16,VS:CCSC15,VS:MSRP15,V:SUMMA15,VGS:IUST14}
\printbibliography[heading=subbibliography,title={Refereed Conference     Publications},type=inproceedings,resetnumbers=true]
%\newrefcontext[labelprefix=M]
\nocite{VS:IUST16,VS:CCSC15,VS:MSRP15,V:SUMMA15,VGS:IUST14}
\printbibliography[heading=subbibliography,title={Miscellaneous},
type=misc,resetnumbers=true]

\end{document}

EDIT 2: Here is the .bib file used in the MWE

 @inproceedings{WLS:ICSE76,
 author = {Wulf, Wm. A. and London, Ralph L. and Shaw, Mary},
 title = {An Introduction to the Construction and Verification of Alphard Programs},
 booktitle = {Proceedings of the 2Nd International Conference on Software Engineering},
 series = {ICSE '76},
 year = {1976},
 location = {San Francisco, California, USA},
 pages = {390--},
 url = {http://dl.acm.org/citation.cfm?id=800253.807708},
 acmid = {807708},
 publisher = {IEEE Computer Society Press},
 address = IEEEAddr,
}

@misc{VS:IUST16,
 author = {Velez, Miguel and Sawin, Jason},
 title = {Improving the Efficiency of CHA through Parallelization},
 howpublished = {Poster. Inquiry at St. Thomas},
 month = {May},
 year = {2016},
}

@misc{VS:CCSC15,
 author = {Velez, Miguel and Sawin, Jason},
 title = {Faster {WAH} Compression Querying through the Use of Metadata},
 howpublished = {Poster. Consortium for Computing Sciences in Colleges Midwest Region},
 year = {2015},
 note = {{1$^{st}$} place Discovery Track},
}

@misc{VS:MSRP15,
 author = {Velez, Miguel and Solar-Lezama, Armando},
 title = {Simpler Implementation of {Sketches} through Enhanced Expressiveness},
 howpublished = {Poster. MIT Summer Research Poster Session},
 year = {2015},
}

@misc{V:SUMMA15,
 author = {Velez, Miguel},
 title = {Current and Future Relationships Between Robots and Humans},
 howpublished = {Summa Cum Laude Paper},
 month = {April},
 year = {2015},
}

@misc{VGS:IUST14,
 author = {Velez, Miguel and Gittins, Peter and Sawin, Jason},
 title = {Extending {SMILES} to Encode Reaction Mechanisms},
 howpublished = {Poster. Inquiry at St. Thomas},
 month = {May},
 year = {2014},
}

Best Answer

If you add the following code in the preamble, this should solve your problem. However, it is not possible to cite correctly the entries. You will get wrong negative numbers when you cite the references.

\makeatletter
\patchcmd{\blx@printbibliography}
  {\blx@bibliography\blx@tempa}
  {\setcounter{bibitemtotal}{0}%
   \begingroup
   \def\do##1{\stepcounter{bibitemtotal}}%
   \dolistloop{\blx@tempa}%
   \endgroup
   \blx@bibliography\blx@tempa}{}{}
\makeatother

\newcounter{bibitemtotal}
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\value{bibitemtotal}+1-#1\relax}
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{\printfield{labelprefix}\printfield{labelnumber}}}
     {}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

Then you can just use the following to print the bibliography with your fileters:

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

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

\newrefcontext[labelprefix=C]
\printbibliography[type=inproceedings,resetnumbers=true]

Edit 1:

The full minimal example is here:

%% pdflatex MWE
%% biber MWE
%% pdflatex MWE
%% pdflatex MWE
\documentclass{article}

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


\makeatletter
\patchcmd{\blx@printbibliography}
  {\blx@bibliography\blx@tempa}
  {\setcounter{bibitemtotal}{0}%
   \begingroup
   \def\do##1{\stepcounter{bibitemtotal}}%
   \dolistloop{\blx@tempa}%
   \endgroup
   \blx@bibliography\blx@tempa}{}{}
\makeatother

\newcounter{bibitemtotal}
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\value{bibitemtotal}+1-#1\relax}
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{\printfield{labelprefix}\printfield{labelnumber}}}
     {}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}


\begin{document}

\cite{A01} \cite{B02} \cite{C03}

\nocite{*}

\newrefcontext[labelprefix=B]
\printbibliography[title={Books},type=book,resetnumbers=true]

\newrefcontext[labelprefix=J]
\printbibliography[title={Journals},type=article,resetnumbers=true]

\newrefcontext[labelprefix=C]
\printbibliography[title={Conferences},type=inproceedings,resetnumbers=true]

\end{document}

And the .bib file used here is:

@book{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}

@article{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  journal = {Journal B},
  url = {tex.stackexchange.com},
}

@inproceedings{C03,
  author = {Cesar, C.},
  year = {2003},
  title = {Copter},
  booktitle = {Conference C},
}

@inproceedings{D04,
  author = {Diocleziano, D.},
  year = {2004},
  title = {De rerum naturae},
  booktitle = {Conference D},
}

@inproceedings{E04,
  author = {Eloise, E.},
  year = {2004},
  title = {Evidence},
  booktitle = {Conference E},
}

The resulting pdf is the following. Resulting pdf after compilation.

Related Question