[Tex/LaTex] Problem using bibunits

bibtexbibunitstexstudio

I am trying to use bibunits package. If I compile the TeX file using the following sequence of commands, it works properly.

pdflatex document
bibtex bu1
pdflatex document
pdflatex document

However, if I compile it using TeXstudio 2.8.8, TeXstudio fails to recognize bibtex entries inside the bibunit. Here is a minimal example.

\documentclass{article}
\usepackage{bibunits}
\usepackage{filecontents}
\begin{filecontents}{mybib.bib}
    @ARTICLE{Meyer2000,
        AUTHOR="Bernd Meyer",
        TITLE="A constraint-based framework for diagrammatic reasoning",
        JOURNAL="Applied Artificial Intelligence",
        VOLUME= "14",
        ISSUE = "4",
        PAGES= "327--344",
        YEAR=2000
    }
    @ARTICLE{Codishetal2000,
        AUTHOR="M. Codish and K. Marriott and C.K. Taboch",
        TITLE="Improving program analyses by structure untupling",
        JOURNAL="Journal of Logic Programming",
        VOLUME= ""43",
        ISSUE = "3",
        PAGES= "251--263",
        YEAR=2000
    }
\end{filecontents}
\begin{document}
    \begin{bibunit}[plain]
        References to the \TeX book \cite{Meyer2000}
        and to Lamport’s \LaTeX\ book, which appears
        only in the references\nocite{Codishetal2000}.
        \putbib[mybib]
    \end{bibunit}
\end{document}

Best Answer

Old question, but exactly my problem. I don't know much about TeXstudio, but I put together a hack to get it to work. There must be a better way. Somebody please post it.

  1. Go to Options->Configure TeXstudio...
  2. Select Commands from the options on the left
  3. Scroll to BibTeX
  4. Update the BibTeX command as described below

The default command should be "bibtex.exe %", which apparently runs bibtex on the main filename (without the extension). I added a list of executions of bibtex on bu# where # is a number from 1 to 9.

So the BibTeX command now looks like:

bibtex.exe % | bibtex.exe bu1 | bibtex.exe bu2 | bibtex.exe bu3 | bibtex.exe bu4 | bibtex.exe bu5 | bibtex.exe bu6 | bibtex.exe bu7 | bibtex.exe bu8 | bibtex.exe bu9

FYI, I am running TeXstudio 2.8.4 on Windows 7

Like I said, a hack. But it seems to work.


Edit: I'm guessing TeXstudio does conditional "recompiles" of the bibliography based on whether it thinks there has been a change. I'm also guessing that it doesn't detect changes well with bibunits. Therefore, I've had to do (at least) three TeXstudio steps when using this hack. First, recompile main tex file. Second, recompile bib file (f11). Third, recompile main tex file again.