[Tex/LaTex] Adding bib item not in bib-file

bibliographiesbibtex

I use Papers to manage all my reference files and produce a bibtex.bib file. In some articles I want to include a reference not in that bibtex.bib file. This is often for things like "personal correspondence". I don't want to have to add a "fake" item in my software to do it.

Is it possible to add an item in my tex source that can then be referenced in the document and appear in the references section?

Best Answer

The whole point of BibTeX and .bib files is that you don't have to write anything ad-hoc in your document. All citable sources are given in the .bib file and can be called upon and formatted as desired in the document.

If you don't want to 'pollute' your main .bib file with certain entries, you can use a second .bib file for these one-off citations. BibTeX can easily process several .bib files. That second .bib file could be created from the .tex file with filecontents (see MWE below, where the 'main' .bib file is created that way).

Of course the output still depends on the way the bibliography style formats your entry. So if you want a 'freeform' citation, you might have to trick BibTeX a bit.

The package notes2bib takes this idea a step further and automates it. It allows you to create one-off bibliography entries from within the document on the fly. Internally, the package just writes a .bib entry to a separate .bib file and tells BibTeX to load it as well.

The package has many options to allow you to customise the output. Depending on the style and the desired output tweaks might be necessary.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[numbers]{natbib}
\usepackage{notes2bib}

% for unsrtnat
\bibnotesetup{
  note-name = ,
  use-sort-key = false
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  year    = {1980},
}
\end{filecontents}

\begin{document}
\cite{appleby}
\bibnote{Personal communication with Sir Humphrey Appleby}
\bibliographystyle{unsrtnat}
\bibliography{\jobname}
\end{document}

[1] Humphrey Appleby. On the Importance of the Civil Service. 1980.//[2] Personal communication with Sir Humphrey Appleby.


If you are not afraid of manual work, you can modify the .bbl file that is produced by BibTeX to typeset the bibliography.

In a simple document it might look like this

\begin{thebibliography}{1}

\bibitem[Appleby(1980)]{appleby}
Humphrey Appleby.
\newblock \emph{On the Importance of the Civil Service}.
\newblock 1980.

\end{thebibliography}

The thebibliography environment works more or less like an enumerate or itemize with \bibitem instead of \item. \bibitem has a mandatory argument: The entry key that you can use in \cite and an optional argument for a citation label or metadata for author-year citation commands. It depends on the citation management package how the optional argument is used and formatted.

You can easily add your own entries here.

\begin{thebibliography}{1}

\bibitem[Appleby(1980)]{appleby}
Humphrey Appleby.
\newblock \emph{On the Importance of the Civil Service}.
\newblock 1980.

\bibitem[Appleby(2018)]{app:perscomm}
Personal communication with Sir Humphrey Appleby.
\newblock 2018.

\end{thebibliography}

The disadvantage of this approach is that the .bbl file is temporary in nature: It is supposed to be rewritten on each BibTeX run.

When you are done, you can replace the \bibliography{\jobname} line with the contents of your .bbl file. That fixes the output and does away with needing to run BibTeX.


If you use biblatex, you can't modify your .bbl file, since the format of the file is different: It does not contain the formatted bibliography, it just contains the raw data in a format readable by LaTeX.

You can still use a second .bib entry or notes2bib. And you might also want to look into How to set up BibLaTeX for use with 'freeform' citations.

Related Question