[Tex/LaTex] Mechanics of BibLaTeX: proper connection of .bib file

biblatextexniccentertexstudio

Ok, I've experienced weird behavior with TeXstudio. I want to add bibliography directly to .bib file while using biblatex. People seem to do in this way. I don't want bibliography inside of the .tex file, but want to separately modify the .bib file – this is the condition

\addbibresource{jobname.bib}

\begin{filecontents}{\jobname.bib}
  @article{JoeDoe2012,
    Author = {Joe Doe},
    Year = {2012},
    Title = {My article's title},
    Journal = {My journal's title},
    Editor = {Ben Editor},
    URL = {http://webpage.com},
  }

\end{filecontents}

In TeXstudio, in order to update (say after adding second item in filecontents), you have to delete all the files except .tex every time . Recompiling dozen times – no reaction, no update. Adding item directly to .bib file – no reaction, no update again after recompiling. During these operations it complains that another .bib file with project name already exists – adding entries there gives no result either. It breaks also when you just try add .bib file without filecontents directly to a .tex file now giving annoying error:

I have no clue what `\addbibresource` command is

Yes, after you've executed it twice with filecontents, same as saying I don't understand what is water while drinking Pepsi. The result is always unresolved references.

In TeXnicCenter it seems that connection occurs after you add two of these and then remove filecontents – now you are able to edit .bib file and recompiling gives you updated results.

I've always wanted to use TeXstudio due to GUI stuff but it keeps me failing over and over again.

Best Answer

It seems to me the easiest way of doing this is by creating a seperate .bib file, for example you can open a new window in your editor, paste your code

@article{JoeDoe2012,
    Author  = {Joe Doe},
    Year    = {2012},
    Title   = {My article's title},
    Journal = {My journal's title},
    Editor  = {Ben Editor},
    URL     = {http://webpage.com},
    }

and save as for example jobname.bib (I wouldn't use backslashes in the filename, this can lead to problems when refering to it in your .tex file) in the same folder as your .tex file is in.

You said

I have no clue what \addbibresource command is

This becomes apparent in the following example file, where it is used to include the bibliography that you enclosed using \begin{filecontents}...\end{filecontents}:

\documentclass{article}
\usepackage[backend=bibtex,style=numeric]{biblatex}
\addbibresource{jobname.bib}
\begin{document}

This statement has a checkable source \cite{JoeDoe2012}.

\printbibliography
\end{document}

The backend=bibtex argument is used to tell biblatex to use bibtex (you could also use biber, which is often preferred) and style=numeric is used to number the citations. The argument \printbibliography simply prints the bibliography at that position.

It might (dependent on which editor you use) be necessary to run pdfLaTeX->BibTeX->pdfLaTeX->pdfLaTeX. If you don't see any updates, it might be useful to delete all output files (.aux, .bbl, etc) before recompiling.

Related Question