[Tex/LaTex] Forcing enumerated \bibitems using bib units

bibliographiesbibunitssubdividing

I'm editing my CV and I wanted to use the bibunits package to make separate mini-bibliographies for different sections. Here is some code:

\documentclass{article}

\usepackage[ManyBibs]{currvita}
\usepackage{bibunits}
\usepackage[pdfborder={0 0 0},breaklinks]{hyperref}
\usepackage{filecontents}

\defaultbibliography{test}
\defaultbibliographystyle{acm}

\newenvironment{cvseclist}[1]
{\phantomsection
\addcontentsline{toc}{section}{\sc #1}%
\begin{cvlist}{\sc #1}}
{\end{cvlist}}

\newcommand\multilinelabel[1]{%
\smash{\parbox[t]{\cvlabelwidth}{\raggedright #1}}%
}

\makeatletter
\newcommand*\pubs[2]{%
\item[\sc \multilinelabel{#1}]
\begin{bibunit}%
    \nocite{#2}%
    \putbib
\end{bibunit}%
\IfFileExists{\@bibunitname.bbl}{}{Run \texttt{bibtex
\@bibunitname}}%
}
\makeatother

\begin{document}

\begin{cv}{Anand D. Sarwate \hfill Curriculum Vit\ae}


\begin{cvseclist}{Publications}
\pubs{Journal Papers}{test1,test2,test3}
\end{cvseclist}

\end{cv}
\end{document}

I couldn't figure out how to use filecontents so it is faster to provide test.bib here:

@article{test3,
Author = {A. D. Sarwate},
Journal = {Baz : Theory and Applications},
Number = {1},
Title = {Baz is meh},
Volume = {1},
Year = {2011}}

@article{test2,
Author = {A. D. Sarwate},
Journal = {IEEE Transactions on Bar},
Number = {2},
Title = {Bar is better},
Volume = {8},
Year = {2010}}

@article{test1,
Author = {A. D. Sarwate},
Journal = {Journal of Foo Studies},
Number = {3},
Title = {Foo is awesome},
Volume = {12},
Year = {2009}}

But when I put in \pubs{Journal Papers}{test1,test2,test3}, I get an unnumbered list of bibitems. What I want is a numbered bibliography, so that it looks something like:

Journal Papers

[1] A.D. Sarwate, "Foo is awesome", Journal of Foo Studies 12(3), 2009.

[2] A.D. Sarwate, "Bar is better", IEEE Transactions on Bar 8(2), 2010.

[3] A.D. Sarwate, "Baz is meh", Baz : Theory and Applications, Los Angeles, CA, June 2011.

and each bibunit is independently numbered. The lack of numbering I see now seems to not change with the bibliography style I use. Is there a way to force BibTeX to number each bibunit?

Is this a problem with \nocite? If I change the command to use \cite then the \cite command produces numbers like [1-3] but the bibliography remains unnumbered.

Best Answer

A solution based on etoolbox is the following

\usepackage{etoolbox}
\newcounter{mybibitem}
\AtBeginEnvironment{bibunit}{\setcounter{mybibitem}{0}}
\makeatletter
\AtBeginDocument{
\apptocmd{\@bibitem}{\stepcounter{mybibitem}[\themybibitem] }{}{}}
\makeatother
Related Question