[Tex/LaTex] Problem compiling with bibunits

bibunits

I have an issue in compiling with bibunits. Even this very simple example does not work for me.

\begin{filecontents}{test_ref.bib}
@inproceedings{code,
   author = "A., B.",
   title = "An amazing title",
   booktitle = "Proceedings of a Conf",
   pages = "1--2",
   year = "2010"
}
\end{filecontents}

\documentclass{article}
\usepackage{filecontents}
\usepackage{bibunits}
\bibliographyunit[\section]
\defaultbibliography{test_ref}
\defaultbibliographystyle{abbrv}

\title{Test}
\author{Test}

\begin{document}
\maketitle
\section{One}
This is a test for Section One~\cite{code}.

\putbib

\section{Two}
This is a test for Section Two~\cite{code}.

\putbib
\end{document}

I compile it with:

latex file
bibtex bu1
bibtex bu2
latex file
latex file

However, in the final dvi there are question marks instead of the numbers of the citations.
What's wrong with it? (I use MikTeX 2.9 updated to the last version of the repository, on Windows 10).

Thanks a lot for your help.

Best Answer

To get bibliographies at the subsection level (i.e. below sections) you should use \usepackage[subsectionbib]{bibunits} not \usepackage[sectionbib]{bibunits}.

\begin{filecontents}{test_ref.bib}
@inproceedings{code,
   author = "A., B.",
   title = "An amazing title",
   booktitle = "Proceedings of a Conf",
   pages = "1--2",
   year = "2010"
}
\end{filecontents}

\documentclass{article}
\usepackage{filecontents}
\usepackage[subsectionbib]{bibunits}

\title{Test}
\author{Test}

\defaultbibliography{test_ref}
\defaultbibliographystyle{abbrv}
\begin{document}

\maketitle

\bibliographyunit[\section]

\section{One}
This is a test for Section One~\cite{code}.

\putbib

\section{Two}
This is a test for Section Two~\cite{code}.

\putbib

\end{document}
Related Question