Background
Now that TeX Live 2010 has a restricted \write18
, I figured it'd be reasonable to update my cv which uses the bibunits
package to run BibTeX for each of the .aux
files.
Currently, I have a macro \pubs
that typesets a label and then the bibliography (\pubs
is used inside a cvlist
environment from currvita
, but that is not important here).
\makeatletter
\newcommand*\pubs[2]{%
\item[#1]
\begin{bibunit}%
\nocite{#2}%
\putbib
\end{bibunit}%
\IfFileExists{\@bibunitname.bbl}{}
{Run \texttt{bibtex \@bibunitname}}%
}
\makeatother
It is used like \pubs{Refereed papers}{foo,bar,baz}
to typeset the bibliography entries corresponding to the citation keys foo, bar, and baz (or it prints a helpful message if BibTeX hasn't been run).
Question
How can I modify this to run bibtex \@bibunitname
and then use the results in a sane way?
One idea I had that mostly works is
\makeatletter
\newcommand*\pubs[2]{%
\item[#1]
\begin{bibunit}%
\nocite{#2}%
\immediate\write\@bibunitaux{\string\bibdata{\bu@bibdata}}%
\end{bibunit}%
\immediate\write18{bibtex \@bibunitname}%
\InputIfFileExists{\@bibunitname.bbl}{}
{Run \texttt{bibtex \@bibunitname}}%
}
\makeatother
Here the \putbib
has been replaced with a write of the \bibdata
and \IfFileExists
has become \InputIfFileExists
. When run, this complains that all of my citations are undefined, but the output looks fine. In particular, all of the aux files are closed before they are read in from the \InputIfFileExists
.