0

I have a main file with a corresponding bib file. Now I want to cite items that are found in an already compiled bbl file. How could one combine the 2?

Ideas:

  1. Add the new \bibitem to main.bbl file, deletes entries upon recompiling
  2. Can one combine multiple bib/bbl files?
  3. Convert bbl files to bib by hand as an answer suggest
  • 1
    You have tagged your question with biblatex, but parts of what I say can also be applied to BibTeX: The .bbl file contains the entries in sorted order, if you want to merge several .bbls it would take some time to get the sort order right. Furthermore for biblatex the .bbl may include context-dependent information such as name uniqueness and disambiguation information, if entries from different .bbls are merged these pieces of information can't be guaranteed to be correct any more. – moewe Dec 11 '18 at 9:59
  • The question mentions \bibitem, which is a BibTeX command and not used in biblatex, explicitly while it is tagged with biblatex. Do you use biblatex and only used \bibitem as a metonymy or do you use BibTeX (and mistagged the question)? – moewe Dec 11 '18 at 10:06
1

What do .bbl files do?

.bbl files are the intermediate data format used to make .bib entries usable in a LaTeX file. Their format and exact use differs between biblatex and BibTeX-based systems.

For BibTeX-based systems (e.g. natbib) the .bbl file contains a thebibliography environment that can be typeset directly. Usually thebibliography is a glorified enumerate environment with a few extra \label-like commands. The .bbl file is (essentially) \input by \bibliography{...} and typeset as is. The format and contents of the .bbl file are controlled by the .bst you gave in \bibliographystyle in your document. BibTeX's .bbl files can be easily edited by hand, indeed the 'manual bibliography method' essentially consists of writing the contents of a .bbl directly into the document (see for example https://www.tug.org/TUGboat/tb30-1/tb94mori.pdf).

For biblatex the .bbl file does not contain typesettable code, instead it contains the original data in a digested format usable for biblatex. The .bbl file is read at the beginning of the document so that all information about all entries is available while the document is processed. Since biblatex allows you to separate your document into several refsections and supports getting data from different refcontexts, the structure of the file can be slightly more complicated than a simple list of all entries with their data. Still ultimately, biblatex's .bbl files are a text-based list structure that can be edited manually if need be.

See also Difference between a .bib and .bbl file for Latex, How tell LaTeX to use existing bbl file without running bibtex?. I have touched on this in Customize citation with bibulous, Making the arXiv accept a BibTeX BBL (May 2018) and Can a LaTeX file include the BibTeX file? and you will probably find many more posts on this site that explain this or mention how .bbls work in passing or in more detail.

Difficulties in merging several .bbl files

One important thing to keep in mind is that both the .bbl files for BibTeX and biblatex are sorted. That means that you must pay attention to the sort order when you merge two .bbl files (by whatever means).

Furthermore .bbl files may contain data not present in the .bib that goes beyond sorting. For biblatex that includes name uniqueness and disambiguation data. Some more advanced author-year BibTeX styles also create year disambiguation labels like the "a" and "b" in "Knuth 1986a, Knuth 1986b" on the fly. If new entries are added, these context-dependent features may not behave as expected any more. Another example of data that is not present in the .bib file itself and calculated by the backend are the alphanumeric labels as produced by alpha.bst or style=alphabetic.

For BibTeX-based .bbl files it would be good if the output of the two .bbl files was compatible so that the output is consistent. This is a given if both .bbls were produced with the same .bst, if that is not the case, manual interventions might be needed. Since biblatex's .bbl files contain only data, this is not a concern for biblatex.

Pasting the contents of .bbl file one into file two

The simple solution to merging .bbl files is to just copy the contents of one .bbl file into another.

Since .bbl files are intended as an auxiliary and temporary bridge between the .bib and the .tex file they are supposed to be overwritten by each BibTeX or Biber run. That means that it is tedious, if very straightforward for BibTeX and fairly straightforward for biblatex, to make manual changes to these files.

All in all I would say this approach is viable if you have only few entries to integrate into your .bbl file and context-sensitive data and sorting play little or no role.

Loading several .bbl files with LaTeX

It is no problem to load several .bbl files with BibTeX, but if you do not manipulate the involved macros, both files will produce separate bibliographies with their own numbering

\begin{document}
\cite{sarfraz,kullback}
\cite{doody,wilde}
\input{bblone.bbl}
\input{bbltwo.bbl}
\end{document}

Two separate bibliographies

Depending on the desired output it might be possible to hack something together that would combine the two .bbl files (more or less) (this is just a proof of concept and absolutely not recommended, it redefines low level commands in a very naive way)

\begin{document}
\cite{sarfraz,kullback}
\cite{doody,wilde}
\makeatletter
\begingroup
% usually \begin{...}\end{...} has an implicit group, we need to get rid of that
\def\begin#1{\csname #1\endcsname}
\def\end#1{\csname end#1\endcsname}
% save the real endthebibliography and disable the end for the first bbl
\let\orig@endthebibliography\endthebibliography
\let\endthebibliography\relax
\input{bblone.bbl}
% remove the beginning and restore the end
\let\thebibliography\@gobble
\let\endthebibliography\orig@endthebibliography
\input{bbltwo.bbl}
\endgroup
\makeatother
\end{document}

One combined bibliography

With biblatex it is possible to obtain the data from different .bbl files as well, see How to import / print a bibliography created from a separate / external document?. But it is more complicated to get things right due to the more complex structure.

So it is theoretically possible to combine .bbls on the the LaTeX side, but that might get very complicated quite quickly and does not solve the issues of sorting and context dependent information.

Converting the .bbl to .bib

My preference would be to convert the contents of your second .bbl back to a .bib file. With that .bib file you can then use BibTeX or Biber as usual.

The conversion does not have to be done by hand, you can use https://text2bib.economics.utoronto.ca/ as suggested in Convert from a textplain reference to bibtex. Of course you have to double check the result and should expect to have to apply some fixes to the result, but as a first approach such a tool can be helpful. The good thing is that you only have to do this once.

There is no issue with loading several .bib files at once, see Bibliographies from multiple .bib files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.