# Internal bibliography with biblatex

I would like to have a paper's bibliography entries inside its .tex file instead of outside in a .bib file. Is this possible with biblatex?

My reason for asking this is that I want to find the most convenient way to produce documents that uses biblatex from just one file to make collaboration on papers easier and to be able to handle submissions of papers to journals.

-
I get very curious as to why you want this. I would expect sending around a bunch of files or using a version control system e.g. git (which is what I do) to be easier but maybe I am missing something? –  jonalv Jun 17 '11 at 16:14

Not really. You can use the filecontents* environment. Put

\begin{filecontents*}{database.bib}
<the bibliography database>
\end{filecontents*}


in the preamble (before \documentclass) and the database.bib file will be created if not already existent. This is the most convenient way to pack everything needed in a unique .tex file.

The filecontents* environment differs from filecontents in that the former doesn't add any initial comments, which could confuse bibtex or biber.

As mentioned by Gonzalo Medina, the filecontents package lifts some restriction about these environments, allowing for example to put them anywhere in the file. Notice that, with this package, existent files will be overwritten.

-
Is this how authors collaborating on papers handle reference entries for biblatex when sending drafts back and forth between each others? –  N.N. Jun 9 '11 at 14:16
@N.N. This is a convenient way; one can always use a compressed archive. Recall, however, that an existent file with the same name will not be overwritten. –  egreg Jun 9 '11 at 14:18
@N.N. In standard LaTeX the environments filecontents and filecontents* have two restrictions: 1) they can only be used before the \documentclass command, and 2) if the file to be created already exists, then nothing happens (except for an information message) and the body of the environment is bypassed. These two restrictions can be lifted if you load the filecontents package. –  Gonzalo Medina Jun 9 '11 at 14:26
@N.N. Yes. This is a good option, but sometimes journals don't accept an archive and the filecontents(*) environment is the option of choice. –  egreg Jun 9 '11 at 14:40
@egreg I guess using version control might be an option too (I'm using git for my own work) but not everyone is prepared to learn one such system. –  N.N. Jun 9 '11 at 14:52

The Journals of Elsevier recommend:

• Open the bbl file; there, you'll see something like that:

\begin{thebibliography}{number_of_bibliography_entries}

bibliography entries

\end{thebibliography}

• Copy all the content in these file;

• Paste the content in your tex file, replacing thebibliography environment.

After that you can define your bibliography style, as example:

\bibliographystyle{plainnat} (if you use natbib).

I hope you can solve your problem.

-
Be warned that this approach will not work if you are still in the stages of adding stuff to your bibliography and sending it to collaborators. –  Seamus Jun 15 '11 at 13:10
I'm not sure, but I don't think \bibliographystyle is supported by biblatex. –  doncherry Jan 8 '12 at 18:49
Be warned that this approach maybe will not work due to the lack of new file create authorization on another server using limited user credentials. –  Sait Sep 11 '12 at 11:26

I don't know about BibLaTeX specifically, but you can do it with BibTeX, although it is sort of silly. BibTeX ignores all text outside of @foo{...}. So what you can do is you can give your .tex file a .bib extension and put the document followed by a \endinput followed by your bibliography entries. Here's an example.

\documentclass{article}
\begin{document}
\nocite{th11}
\bibliographystyle{plain}
\bibliography{\jobname}
\end{document}
\endinput

@misc{th11,
author = {T.H. Me},
title = {Silliness},
year = 2011,
month = jun,
}


One can compile this using the following.

$pdflatex b.bib$ bibtex b
$pdflatex b.bib$ pdflatex b.bib

-
This works provided the @ character never appears in the document before the bibliographic data. If, for instance, an email address appears, it breaks BibTeX. –  egreg Jun 14 '11 at 10:27
@egreg: Yep! As I said, this is sort of silly. –  TH. Jun 14 '11 at 10:35
If there were a sort of \endinput for BibTeX (or Biber), one might put the bibliographic data in front of the file, surrounded by \iffalse and \fi; but I don't think something like @ENDINPUT exists. However this would still require naming the file with the .bib extension. –  egreg Jun 14 '11 at 10:55