# biblatex continuous reverse numbering all but one category

I am updating my cv and the answer biblatex continuous reverse numbering... to my previous question solved my problem, until I realized that I should not count my unpublished articles (which I would like to show right after the published ones), the problem thus is:

**Articles (3)**
[6] great Article 2
[5] great Article 2
[4] great Article 1

**Submitted but unpublished Articles (2)**
- hopefully soon published Article 2
- hopefully soon published Article 1

**Presentations (2)**
[3] great Presentation 2
[2] great Presentation 1

**Thesis**
[1] great Thesis


I figured out by following this idea count references in \AtDataInput how to count just the items in a given category \iscategory{article} does the trick in the \ifboolexpr{}{}{} - which works great!

-

The general approach taken in the linked questions can be used here, but you'll have to adjust the labelnumber format for unpublished works. For published works, the item total needs to be corrected once the list of unpublished works is printed.

Here is an example that extends to various stages before publication, as indicated by the pubstate field.

\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=numeric,sorting=ydnt,defernumbers]{biblatex}

\makeatletter
\def\forcategory#1{\forlistloop{#1}{\blx@categories}}
\def\ifskipbib{\iftoggle{blx@skipbib}}
\makeatother

% Print labelnumber as item total, minus actual number, plus one
\DeclareFieldFormat{labelnumberwidth}{\iffieldundef{pubstate}{\mkbibbrackets{#1}}{#1}}
\DeclareFieldFormat{labelnumber}{\iffieldundef{pubstate}{\mkbibdesc{#1}}{--}}
\newrobustcmd{\mkbibdesc}[1]{\number\numexpr\value{itemtotal}+1-#1\relax}
\newcounter{itemtotal}

\def\countinit#1{\csnumgdef{count:#1}{0}}
\forcategory{\countinit}

% Add entries to categories, increment entry totals
\ifboolexpr{ test {\ifentrytype{#1}} and not test {\ifskipbib} }
{\iffieldundef{pubstate}
\csnumgdef{count:#1}{\csuse{count:#1}+1}%
\stepcounter{itemtotal}}
\csnumgdef{count:unpublished}{\csuse{count:unpublished}+1}}%
\listbreak}
{}}

\renewbibmacro*{in:}{%
\iffieldundef{journaltitle}{}{\printtext{\bibstring{in}\intitlepunct}}}

\def\defbibtitle#1#2{\csdef{title:#1}{#2}}
\ifcsundef{title:#1}{\MakeCapital{#1s}}{\csuse{title:#1}}%
\ifnumgreater{\csuse{count:#1}}{1}{~(\csuse{count:#1})}{}%
\ifstrequal{#1}{unpublished}
{\global\defcounter{itemtotal}{\value{itemtotal}+\csuse{count:#1}}}{}}}}

\DeclareBibliographyCategory{article}
\DeclareBibliographyCategory{unpublished}
\DeclareBibliographyCategory{report}
\DeclareBibliographyCategory{inproceedings}

\defbibtitle{unpublished}{Unpublished articles}
\defbibtitle{inproceedings}{Presentations}

\begin{filecontents}{\jobname.bib}
@article{submit,
author = {Last, First},
title = {Title},
journaltitle = {Journal},
date = {2012},
pubstate = {submitted}}
@article{inprep,
author = {Last, First},
title = {Title},
date = {2012},
pubstate = {inpreparation}}
\end{filecontents}
\begin{document}
\bibbycategory
\end{document}


Some notes:

• This approach is suited only for use with \nocite in one reference section. Some extensions have been demonstrated in related questions.

• The document will typically require an extra LaTeX run to compile, even if biblatex doesn't generate a "rerun LaTeX" warning in the log.

• A localization key should be used in the pubstate field. Keys can be redefined in the preamble using \DefineBibliographyStrings. For further details refer to the biblatex manual.

• A descending labelnumber emphasizes the total number of works, but here you're counting apples and oranges. This format is probably best suited for CVs with a list of peer-reviewed articles that spans more than one page.

-
Thanks Audrey, exactly what I needed, took me a while to get through your approach with automatic section labeling - I had to revise my own code, 'cause yours is better. –  harry Sep 5 '12 at 20:24
@harry No problem. About your code - it's usually a good idea to post what you have so far in your question. Answering your own question is OK, too. –  Audrey Sep 5 '12 at 22:42