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.

Is there a way to have references in the same latex file (i.e. instead of having the references in a separate .bib file)

share|improve this question
1  
Welcome to TeX.SE! You could, for example, use the filecontents package to provide the bibliographic entries in the preamble of your document. For a practical example of this approach, see the posting tex.stackexchange.com/a/185067/5001. –  Mico Jun 16 at 5:54
    

3 Answers 3

Yes and no.

You can create your own bibliography manually:

\begin{thebibliography}{xx}
  \bibitem{abc}
  \textsc{Author}, \textit{Title}, ...

  ...

\end{thebibliography}

However, this lacks consistency through automation as well as ease-of-maintenance.

A far better alternative to handling a bibliography "within the same file" would be to embed it via the aid of filecontents. The package provides the ability to overwrite existing files via the filecontents* environment. This way you can manage your bibliography within the main TeX file, while it is actually always written out to file for use in the expected way.

Here is an example:

\documentclass{article}

\usepackage{biblatex}

\usepackage{filecontents}

\begin{filecontents*}{general.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
\end{filecontents*}

\addbibresource{general.bib}

\nocite{*}

\begin{document}

\printbibliography

\end{document}

The file general.bib is overwritten with every compilation, allowing you to add/remove bibliography entries as you please. Every change, however, should still be accompanied with the appropriate BibTeX engine (biber in the above case).

share|improve this answer
    
this code needs a biblatex.sty file, how to do that? –  user3741635 Jun 16 at 13:28
    
@user3741635 you need to install biblatex. On miktex and texlive there are package installers to do this for you. –  Chris H Jun 16 at 15:24
    
@user3741635: You can follow the direction in How do I update my TeX distribution? to install packages. If you're talking about the general use of a bibliography and how to obtain/display it in your document, then that's a different question. That requires a compilation sequence (pdf)LaTeX > BibTeX/Biber > (pdf)LaTeX (and possibly one more (pdf)LaTeX). –  Werner Jun 16 at 15:37
    
is it possible to add references to this file \documentclass{article} \title{Hello} \author{My Name} \begin{document} \maketitle \section{Introduction} A1 \section{Literature Review} A2 \section{Conclusion} A2 \end{document} –  user3741635 Jun 16 at 17:36
    
@user3741635: Yes. –  Werner Jun 16 at 17:42

In case this is the request of a publisher who wants only one file compiling with standard packages only, the classical way of doing this is:

  1. Use bibtex as usual when preparing your manuscript, say manuscript.tex.

  2. Before sending to the publisher, make a copy your manuscript .tex file, say to submitted_version.tex, edit that copy and replace the lines calling Bibtex by the contents of the manuscript.bbl file.

Send that file submitted_version.tex to the publisher.

share|improve this answer
    
Though this is common, all cases I've come across for this require bibtex not biblatex - be warned :) –  Chris H Jun 16 at 15:23

In addition, you may use the amsrefs-package.

According to the documentation, there are three ways of using the package:

  1. Enter bibliography items directly in your LaTeX-document using the biblist-environment and the \bib-command.
  2. Import items from an external .ltb-file.
  3. Import items from a .bib file using BibTeX and the special bibliography styles distributed with the amsrefs-package

Item 1 is the method you are asking for. The amsrefs-package is included in TeX-distributions.

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.