[Tex/LaTex] Multibib, do NOT reset reference counter

bibliographiesmultibibsubdividing

Using the multibib package, I have two bibliographic sections.
I do not want the reference counter to be reset, which I had thought should be the default case. At least this is what the package documentation says, and reading the package code, the option resetlabels is off by default. But each bibliography starts counting from one.
Here comes a MWE (file mwe.tex):

\documentclass[12pt]{article}

\usepackage[numbers]{natbib}
\usepackage{multibib}
\newcites{wwwbib}{Links to Webpages}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section*{Test multibib}
Reference to Buzz Lightyear \cite{ref01}.
The reference to Pixar I would expect to be number 2, but it is not \citewwwbib{ref02}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bibliographystyle{plainnat}
\bibliography{mwe}{}
\bibliographystylewwwbib{plainnat}
\bibliographywwwbib{mwe}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

To compile, I use

pdflatex mwe
bibtex mwe
bibtex wwwbib
pdflatex mwe
pdflatex mwe

The content of file mwe.bib is as follows:

@article{ref01,
   author = {Lightyear, Buzz},
   title = {To Infinity and Beyound Part 1},
   journal = {Unknown},
   volume = {54},
   number = {4},
   pages = {331-390},
   year = {2001}
}

@misc{ref02,
   author = {Pixar},
   title = {Pixar Website},
   howpublished = {\url{www.pixar.com}},
   year = {2001}
}

The pdf output is

enter image description here

How can I get continuous numbering?

Best Answer

With my current MiKTeX 2.9 and multibib, version multibib 2008/12/10 v1.4 I get the following (wrong) file wwwbib.aux:

\citation{ref02}
\bibstyle{plainnat}
\bibdata{wwwbib}
\bibcite{ref02}{{2}{2001}{{Pixar}}{{}}},

Because there exists no file wwwbib.bib (line 3) reference ref02 is invalid. After changing wwwbib to test (the bib file is named test.bib) it worked.

The reason for this is that I usualy prefer to write an filecontents part like this to keep created bib or other file with the same name my MWE file has:

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}                   % <==========
...
\end{filecontents*}
...
\bibliographystyle{plainnat}
\bibliography{\jobname}       % print here            % <==========
\bibliographystylewwwbib{plainnat}
\bibliographywwwbib{\jobname} % print here Online bib % <==========

If you use package multibib, this package uses itself macro \jobname to create file wwwbib.aux with \jobname.aux and \bibdata{\jobname} for the needed \bibdata{test}.

It seems that here is a bug in multibib (or in the system or filecontents for using \jobname, resulting in the wrong line \bibdata{wwwbib} (instead of the correct \bibdata{test}).

Solution:
Do not use \jobname for filecontents if you need to use multibib in your MWE!

Result:

The following MWE runs without errors on my system:

\RequirePackage{filecontents}
\begin{filecontents*}{test.bib}                  % <==========
@article{ref01,
  author  = {Lightyear, Buzz},
  title   = {To Infinity and Beyound Part 1},
  journal = {Unknown},
  volume  = {54},
  number  = {4},
  pages   = {331--390},
  year    = {2001},
}
@misc{ref02,
   author       = {Pixar},
   title        = {Pixar Website},
   howpublished = {\url{www.pixar.com}},
   year         = {2001},
}
\end{filecontents*}

\documentclass[12pt]{article}

\usepackage[numbers]{natbib}
\usepackage{multibib}
\newcites{wwwbib}{Links to Webpages}       


\begin{document}
\section*{Test multibib}
Reference to Buzz Lightyear \cite{ref01}.
The reference to Pixar I would expect to be number 2, 
but it is not \citewwwbib{ref02}.     

\bibliographystyle{plainnat}
\bibliography{test}                     % <========== no \jobname here!
\bibliographystylewwwbib{plainnat}     
\bibliographywww{test}                  % <========== no \jobname here!

\end{document}

I got the wanted result: enter image description here

Related Question