8

Hi I'm using TexStudio to write a LaTeX document and am having trouble with my references. I'm using the natbib package and it works fine until I add a new references to my .bib file. When I then try and cite that reference in the main document is comes up with "[?]".

Looking at the file path where I am saving it to, when I compile my document it creates several other files (.toc etc.) but the .bbl does not get overwritten. It stays the same as before I changed my .bib file.

How do I change this so that I overwrite the .bbl file when I include a new reference?

Mico
  • 506,678
  • If I delete the bbl file in the folder, then compile again the references appear. But I don't want to do this everytime. – Callum Hartley Dec 02 '15 at 14:00
  • 3
    You need to run BibTeX so that the .bbl is created. If the .bib file changed it is a good idea to run BibTeX, you don't have to run it after every change to then document. There are tools such as latexmk that can do this automatically (there is also arara, but I don't know how that works). How do you compile your document at the moment? – moewe Dec 02 '15 at 15:09
  • 1
    I have re-tagged your question. You state that you are using natbib so biblatex isn't really relevant here. For reference Question mark instead of citation number. – moewe Dec 02 '15 at 15:11

1 Answers1

5

The natbib citaton management package does not, by itself, update the bbl file which contains the formatted references. Editing the bib file(s) also does not update the bbl file.

To update the bbl file, you first need to re-run LaTeX so that all citations generated by various \cite instructions are up-to-date in the aux file. Then (re)run BibTeX. BibTeX consults the aux file to find out (a) which bibliography style should be employed, (b) which entries are cited, and (c) the name(s) of the bib file(s) that contain the unformatted entries. From these three inputs, and assuming that all information is provided correctly (i.e., no syntax errors and no missing files), BibTeX generates the bbl file as its main output. (Another output is the BibTeX log file, extension blg.)

Once the bbl file is created/updated by BibTeX, you need to rerun LaTeX twice more. During the first pass, the updated bbl file is read in and citation cross-references are resolved (and written to the aux file). During the second pass, LaTeX reads in the information about the citation cross-references to generate the citation call-outs in the format specified by (a) the bibliography style and (b) any options set by natbib.

Mico
  • 506,678
  • 1
    That's great it it working now. Is there a simple way to do this each time I compile? I have found a way to do it from the windows command line, but having it automatically done whenever I press F6 would be great.

    I'm using TeXstudio

    – Callum Hartley Dec 03 '15 at 15:40
  • @CallumHartley - I'm afraid I can't help you with TeXstudio-related questions. (I use a different front-end program.) I'm virtually certain, though, that it should be straightforward to set up a single keystroke-based action that executes LaTeX, BibTeX, and LaTeX twice more. You may also want to look into using arara, a utility that can be programmed extremely flexibly for just such cases. – Mico Dec 03 '15 at 15:57
  • That's alright, I have searched further into this and found a shortcut built into the TeXstudio that updates the bbl file. Thank you very much for your help! – Callum Hartley Dec 08 '15 at 13:15