BibTeX, biblatex and biberBibtex in same file

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
daviddoria
Posts: 60
Joined: Tue Sep 30, 2008 9:24 pm

Bibtex in same file

Post by daviddoria »

I know you can do:

Code: Select all

\begin{thebibliography}{9}
 
\bibitem{test}
  Leslie Lamport,
  \emph{\LaTeX: A Document Preparation System}.
  Addison Wesley, Massachusetts,
  2nd Edition,
  1994.
 \end{thebibliography}
if you just have a few references and don't want to make a separate .bib file, but is there anyway to do it in more of this style:

Code: Select all

@ARTICLE{supercurves,
    AUTHOR={Minghui Xia},
    TITLE={Image Registration by "Super-Curves"},
    JOURNAL={IEEE Transactions on Image Processing},
    YEAR={1985},
	VOLUME = {13},
    PAGES={720},
}
where it takes care of the formatting, etc, for you (like it does when you use a separate bib file)?

Thanks,

Dave

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Bibtex in same file

Post by frabjous »

You could use bibtex, but put the .bib file inside the .tex file with the filecontents environment. (Either put it at the very beginning of the file, or else use the filecontents package.)

Code: Select all

\begin{filecontents}{shortbib.bib}
@ARTICLE{supercurves,
    AUTHOR={Minghui Xia},
    TITLE={Image Registration by "Super-Curves"},
    JOURNAL={IEEE Transactions on Image Processing},
    YEAR={1985},
   VOLUME = {13},
    PAGES={720},
}
\end{filecontents}

\documentclass{article}
\title{A Silly Article}
\author{Me}
\begin{document}
\maketitle
My favorite article is \cite{supercurves}.
\bibliographystyle{plain}
\bibliography{shortbib}
\end{document}
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Bibtex in same file

Post by josephwright »

In addition to the above suggestion, you could look at amsrefs.
Joseph Wright
daviddoria
Posts: 60
Joined: Tue Sep 30, 2008 9:24 pm

Bibtex in same file

Post by daviddoria »

Awesome - that works, thanks. However, I get a warning:

Code: Select all

File `shortbib.bib' already exists on the system.
Is there a way to suppress it? Or should I just ignore it?

Dave
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Bibtex in same file

Post by localghost »

In the solution of frabjous there's a catch which manifests in the warning you get. As long as the *.bib file already exists, modifications in the filecontents environment will have no effect. The *.bib file will not be overwritten. For example, if you decide to add an entry for the database inside the filecontents environment, this will not be added to the written file.


Best regards
Thorsten
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Bibtex in same file

Post by frabjous »

You can of course manually delete the .bib file, and then your changes will take effect...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Bibtex in same file

Post by localghost »

The filecontents package eliminates the limitation I described in my last reply.
daviddoria
Posts: 60
Joined: Tue Sep 30, 2008 9:24 pm

Re: Bibtex in same file

Post by daviddoria »

Excellent - thanks all!
Post Reply