Is there a way to include the BibTeX content in the LaTeX file?
The issue came up during a revision submission to a journal. I could submit a new main file but I did not see a way of submitting a new BibTeX file. So the natural question was if I can combine them into a single file
Best Answer
filecontents
Phelype Oleinik mentions the
filecontents
environment in the comments and purely from the title of your question I would have said that is what you are looking for (assuming that BibTeX file means.bib
file).filecontents
can be used to include an arbitrary file in a.tex
file. That file will be written into the working directory (usually the folder where your main.tex
file lives), if it does not exist already (if additionally you load thefilecontents
package,filecontents
overwrites existing files) when TeX compiles the.tex
file.So
Will produce a
.bib
file with the same name as the.tex
file and that file can then be used to produce the bibliography.filecontents
is extremely useful if you want to provide self-contained files for other people for testing, it is also very good for MWEs on this site. But it is usually not what publishers want when they ask you to submit the bibliography in your.tex
file. This is what the body of your question seems to be about. Publishers then usually talk about the.bbl
file..bbl
files for BibTeX-based bibliographiesWhen you compile the example from above with LaTeX, BibTeX, LaTeX, LaTeX you get a document with a fully working bibliography. The key to that bibliography is the
.bbl
file that is produced by the BibTeX run. You can learn more about it at Question mark or bold citation key instead of citation number, but in a nutshell the.bbl
file contains the bibliography in a format that is ready to typeset for LaTeX in athebibliography
environment that one could also produce manually.The
.bbl
file for the example above contains (amongst others, I shortened it a bit)that code can be directly typeset by LaTeX.
Indeed, if you replace the the line
from the example above with the entire contents of the
.bbl
and throw out thefilecontents
to obtainyou get a document that can be compiled with LaTeX alone to produce the same document with a bibliography and working citations.
This is what many publishers would like you to submit, since that is one document that contains all typesettable material directly and does not require additional runs of auxiliary tools like BibTeX. See also https://www.overleaf.com/help/219.
Some journals may not need you to copy the contents of the
.bbl
file into the.tex
file directly and instead ask you to submit the.tex
and.bbl
file together, but they rarely want the.bib
file..bbl
files forbiblatex
.bbl
files forbiblatex
do not contain ready-to-typeset TeX code, instead they contain the extended and sorted raw data in a format that is easier to digest for LaTeX than the.bib
files The formatting still has to be done on thebiblatex
side. That means that it is not as easy to just copy and paste the.bbl
contents.It is possible to include a
biblatex
-.bbl
into a.tex
as explained in Biblatex: submitting to a journal, but that is rarely what journals want or need. For one the.bbl
file is intimately tied to a specific version ofbiblatex
(and Biber), which means that your version and your publisher's version of the software must be the same. Secondly, not many publishers can deal withbiblatex
anyway as it requires a different workflow than BibTeX-based bibliographies, so it is unlikely that they can accept a submission even if you include the.bbl
file and you have matching versions.People submitting to the arXiv, which allows
biblatex
submissions, often have version problems and need to find old versions ofbiblatex
and Biber to make things work. See Making the arXiv accept a BibTeX BBL (May 2018).