Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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
\def\countadd#1{%
  \ifboolexpr{ test {\ifentrytype{#1}} and not test {\ifskipbib} }
    {\iffieldundef{pubstate}
       {\addtocategory{#1}{\thefield{entrykey}}%
        \csnumgdef{count:#1}{\csuse{count:#1}+1}%
        \stepcounter{itemtotal}}
       {\addtocategory{unpublished}{\thefield{entrykey}}%
        \csnumgdef{count:unpublished}{\csuse{count:unpublished}+1}}%
     \listbreak}
    {}}
\AtDataInput{\forcategory{\countadd}}

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

\def\defbibtitle#1#2{\csdef{title:#1}{#2}}
\def\defbibsubheading#1{%
  \defbibheading{#1}{\subsection*{%
    \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}

\defbibheading{bibliography}{\section*{Publications and Presentations}}
\defbibtitle{unpublished}{Unpublished articles}
\defbibtitle{inproceedings}{Presentations}
\forcategory{\defbibsubheading}

\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}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{glashow,bertram,chiu,companion,padhye,submit,angenendt,moraux,inprep}
\printbibheading
\bibbycategory
\end{document}

enter image description here

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.