I have different categories (filters) for entries in a bibliography using
biblatex (see below). I would like to add a numbering to the entries. Since the
entries are sorted by year in decreasing order, the numbering (in each category)
should also be decreasing.
Basically, I see two routes to go:
1) The first is to use style=numeric and a solution presented here.
However, in my (not so minimal) example, there appeared two problems. First, the
number does not start over again for each of the categories (instead, it
continues). Second, I obtained weird numbers (up to 400), although I only had a
couple of entries with the same keyword.
2) The second (probably easier) I found here. This is actually a nice idea (and lets you specify the numbering etc.), but I
couldn't figure out two things: First, how to get decreasing numbering. Second,
if you have > 9 entries, the space reserved for the label is too small and the
10th entry is not vertically aligned with the 9 before. This can probably be
adjusted with itemindent, but when I tried, the adjustments did not have an
effect.
\documentclass{scrartcl}
% packages
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[
backend=bibtex,
style=authoryear,% numeric,
sorting=ydnt% sort by year (descending), name, title
]{biblatex}
% create dummy .bib file
\usepackage{filecontents}
\begin{filecontents*}{mybib.bib}
@article{mykey1,
author={I Me},
journal={Journal of LaTeX questions},
pages={1--10},
title={My first LaTeX problem},
volume={2},
number={2},
year={2011},
keywords={published}}
@article{mykey2,
author={I Me},
journal={Journal of LaTeX questions},
pages={1--10},
title={My second LaTeX problem},
volume={1},
number={1},
year={2012},
keywords={submitted}}
@article{mykey3,
author={I Me},
journal={Journal of LaTeX questions},
pages={1--10},
title={My third LaTeX problem},
volume={3},
number={3},
year={2013},
keywords={submitted}}
\end{filecontents*}
% bibliography settings
\setlength{\bibhang}{1em}% separate bibitems by indentation
\defbibheading{submitted}{\large\sffamily Submitted}% heading
\defbibheading{published}{\large\sffamily Published}% heading
\defbibfilter{submitted}{keyword=submitted}% filter
\defbibfilter{published}{keyword=published}% filter
\addbibresource{mybib.bib}% bibliography data
% % Idea 1)
% \AtDataInput{%
% \csnumgdef{entrycount:\therefsection}{%
% \csuse{entrycount:\therefsection}+1}}
% \DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
% \newrobustcmd*{\mkbibdesc}[1]{%
% \number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}
% Idea 2)
\defbibenvironment{bibliography}
{\enumerate{}
{\setlength{\leftmargin}{\bibhang}% => adjustments seem to have no effect
\setlength{\itemindent}{-\leftmargin}% => adjustments seem to have no effect
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endenumerate}
{\item}
\begin{document}
\section*{Publications}
\nocite{*}
\printbibliography[heading=submitted, filter=submitted]
\noindent\printbibliography[heading=published, filter=published]
\end{document}
Some more information
1) bibtex as backend is used here on purpose (so that texi2pdf runs biblatex automatically)
2) This problem comes from a CV. The idea is to use \nocite{*} (and not specific \cite{...}s so that I don't have to care about updating the references).
3) In the CV, I show categories "In preparation", "Submitted", "Published", "Book contributions", "Books". I use the following filtering to get this:
\defbibfilter{inpreparation}{type=article and keyword=inpreparation}
\defbibfilter{submitted}{type=article and keyword=submitted}
\defbibfilter{published}{type=article and keyword=published}
\defbibfilter{bookcontrib}{type=incollection and ( keyword=inpreparation or keyword=submitted or keyword=published )}
\defbibfilter{book}{type=book and ( keyword=inpreparation or keyword=submitted or keyword=published )}
biberas backend? I usedbibtex(see Update), but I obtain output containingDatabase file #1: foo-blx.bib Database file #2: biblatex-examples.bib... 2) The whole problem is part of a CV (see the update above). My fear with your solution (although I can't try) is that the numbering is relative to all\nocite{*}"entries" and not just counts the entries shown in the bibliography. I definitely wouldn't want having to\cite{}all entries by hand. – Marius Hofert Feb 11 '13 at 07:10biblatex-examples.bibwheretexi2pdfexits abnormally. For my own.bib, compiling works well and the numbers are decreasing. However, they are still not correct, the reason being that my filters are of the formtype=article and keyword=primary, not justkeyword=primary(or eventype=incollection and ( keyword=primary or keyword=secondary )). For example, you don't want to mix books and articles (=> filter different types as well). Because of this subsetting, some of the numbers are missing. Is there a solution to that? – Marius Hofert Feb 11 '13 at 07:49numericstyle: How does one get the years printed as for theauthoryearstyle (right after the authors' names)? – Marius Hofert Feb 11 '13 at 08:29typeandkeyword? Anything else? A solution relies on exactly how you're splitting the bibliographies. Without accurate information on this, I can't offer a solution. You should have no problem using BibTeX. You can also use\nocite{*}, but again if your bib file is large relative to the number of printed entries\labelnumberwidthis going to be too wide. There are ways around this, but I need more details on the filters. – Audrey Feb 11 '13 at 14:22typeandkeywordin the two ways I showed in my second-last post. Apart from the numbering, which (due to this filtering) is not correct so far, and the fact that I don't know how to get years printed as inauthoryearstyle (but that's rather a detail), everything works. I updated my post to show the exact filters I use in the original example. – Marius Hofert Feb 11 '13 at 14:53authoryearstyle is easy to do. Can\labelnumberwidthpose an issue? In other words, does yourbibfile contain many entries that aren't printed? – Audrey Feb 11 '13 at 15:02.bibfile contains many entries (all papers/books I have ever cited), but I grab all that correspond to the filtering (which are mainly my own papers etc.). – Marius Hofert Feb 11 '13 at 15:30\setlength{\labelwidth}{\widthof{[10]}}in the redefinition of `bibliography. This guaranteed that different categories (one with < 10, one with >= 10 entries) get correctly vertically aligned. – Marius Hofert Feb 11 '13 at 19:20\labelnumberwidth. You can omit the relevant code in the patch if you prefer to set the label width manually. – Audrey Feb 11 '13 at 20:02{\printtext[labelnumberwidth]\printfield{labelnumber}}}with{\printtext[labelnumberwidth]{\printfield{labelprefix}\printfield{labelnumber}}}, no need for anything else to calculate widths. – nonKreon Dec 27 '19 at 18:00\printbibliography[filter=primary,title={Primary articles (\thelabelnumber)}]? – Frederick Nord Dec 02 '21 at 13:27