# Problem compiling with 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.

• welcome to tex.sx. did you run bibtex and then latex twice again? this might be relevant: Question mark instead of citation number Jun 3 '16 at 16:22
• Hi, thanks for your answer. Yes, I run latex, then bibtex (on both the files bu1 and bu2), and then latex twice. I get an error: No file bu.aux. When I compile with "\begin{bibunit}...\end{bibunit}" (instead of "\bibliographyunit[\section]") everything goes fine. Parhaps, it is a bug of the package. Jun 4 '16 at 10:16
• I've seen the same problem with a file I'm working on. As a quick fix, I did cp bu1.aux bu.aux. Then I saw another problem about Missing } inserted. Writing \putbib} got that error to go away and things seem to be working OK. Not a very clean solution, but perhaps a similar work-around will work for you. Aug 6 '16 at 21:21

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}