Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a master BibTeX file that gets updated and maintained by BibDesk. I link to it from my TeX documents, but would sometimes like to add "on the fly" references without having to add these to BibDesk in order for them to get put into the master file. In other words, I would like the option to "mix in" additional \bibitems into my bibliography, something like:

\bibliographystyle{plain}
\bibliography{/Users/Papers/master.bib}
\bibitem{additional}Authors, paper, etc.

(Of course, this gives errors.) Any suggestions? Many thanks, and my apologies if this is a very standard or silly question.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

There are two solutions possible:

1. Patch the \end{thebibliography} as follows:

\AtEndEnvironment{thebibliography}{
% all your extra bibitems go here
\bibitem{extra1}A. Uthor, Some Extra Paper, vol 123, p.2--3 
}

Do not forget to put \usepackage{etoolbox} somewhere in the preamble. MWE:

\documentclass{article}

\usepackage{etoolbox}

\begin{document}

\AtEndEnvironment{thebibliography}{
% all your extra bibitems go here
\bibitem{extra1}A. Uthor, Some Extra Paper, vol 123, p.2--3 
}

Cite from above \cite{extra1}.
Cite from bib-file \cite{bookWhatever}.

\bibliographystyle{plain}
\bibliography{/Users/Papers/master.bib} 

\end{document}

2. Create a "local" bib file.

Basically, the same trick, as has been suggested already by R. Schumacher.
But, if you prefer to keep everything in one .tex file, just do like in the following MWE:

\begin{filecontents}{mylocalbib.bib}
@article{extra1,
  title={Title},
  author={A. Uthor},
  journal={PRL},
  volume={12},
  pages={123--124},
  year={1999},
}
\end{filecontents}

\documentclass{article}

\begin{document}
\cite{extra1}

\bibliographystyle{plain}
\bibliography{/Users/Papers/master.bib,mylocalbib} 
% here both your "global" and "local" bib-files are mentioned

\end{document}
share|improve this answer
    
I think you need to add \usepackage{filecontents} to your preamble to make alternative (2) work, see filecontents documentation –  vaettchen May 2 '12 at 5:33
    
@ vaettchen: no, actually, you don't –  amorua May 2 '12 at 9:55
    
Nice, thanks very much! –  Skeptic May 2 '12 at 12:55
    
Your second solution worked nicely, but it's your first one I would really prefer. Unfortunately, it doesn't seem to be doing anything. Here's what my code looks like at the end of the document: \bibliographystyle{plain} \bibliography{/Users/Papers/master.bib} \AtEndEnvironment{thebibliography}{ \bibitem{extra1} A. Uthor, Some Extra Paper, vol 123, p.2--3 With etoolbox loaded. Any suggestions? Thanks again. –  Skeptic May 2 '12 at 16:44
    
I added a MWE to my first solution. Just try copy-pasting it and compiling with latex, bibtex, latex, latex. Note that bibtex will complaint 'Warning--I didn't find a database entry for "extra1"' –  amorua May 4 '12 at 6:41

I teach my students to use JabRef. And in this case simply have a second *.bib file with the local additions. Assume you call it mybib.bib, keep it in the same folder as the main document, then you would use \bibliography{/Users/Papers/master.bib,mybib.bib}. JabRef runs on Windows, Mac, and Linux. The advantage of this is that you can either keep separate mybib.bib in each folder or use a common one located in your /Users/Papers/ folder.

The only important caution is that if you have duplicate keywords in the different *.bib file it will use the first one it finds in the order in the \bibliography command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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