Odd Bibtex behaviour in a Latex document
Asked Answered
T

5

5

I added a line "\cite{test}" as a test to my working Latex document. When I compiled the bibtex "!bibtex name_of_my_file, I got the expected error:

Warning--I didn't find a database entry for "test"

Then, I removed the line and compiled the bibtex again, hoping to have a working Latex file again. However, the same error occurs, even with a fresh shell. I cannot understand the behaviour. What is the logic? How can I get my Latex document working again?

[Updated Info] The problem dissapeared as unexpectedly as it emerged. I have no idea why but it works now. Do you know the reason for the odd behaviour?

Thermotherapy answered 16/4, 2009 at 20:17 Comment(0)
N
10

I think you are tripping over the multi-pass nature of LaTex plus Bibtex. If you look at Step 3 in this discussion, you'll see the following:

The first run (through latex) generates an auxiliary file, paper.aux, containing information about citations (and other types of references), the bibliography style used, and the name of the bibtex database. The second run (through bibtex) uses the information in the auxiliary file, along with the data contained in the bibtex database, to create a file paper.bbl. This file contains a thebibliography environment with \bibitem entries formatted according to the bibliography style specified.

So, what I think is happening is that your name_of_my_file.aux file still contains your placeholder \cite{test}. If you remove the auxiliary file, you should be able to start over with:

latex name_of_my_file
bibtex name_of_my_file
latex name_of_my_file
latex name_of_my_file

[Update based on additional info]: The problem was that you had a .aux file with your \cite{} still embedded. The second time that you ran latex, you overrode the old file with the new. That's why the complete set of steps includes an initial latex call, a bibtex call and two follow-up latex calls. Think of it as a multi-pass compiler and it might be more intuitive.

Naseby answered 16/4, 2009 at 20:27 Comment(3)
It is even possible to get the aux file into a sufficiently bad state that LaTeX quits before writing a new aux file (this has happened to me), and probably also to a state that is propagated into the new aux file even though the TeX file no longer produces it (this is just speculation and might make a fun research problem). To be sure that your document is reproducible, you need to remove the aux file before the command sequence.Granese
Very true - if you're really panicked, the one file that you must keep is name_of_my_file.tex.Naseby
"The second time that you ran latex, you overrode the old file with the new." I did more than two times. I run the command "!bibtex the_file" at least 50 times, and the command "pdflatex %" about 30 times. It may well be some other reason. Perhaps, it is due to the Mac OS, or something like that. Dunno.Miry
L
3

You could have a look at latexmk, which will take care of the fix point compilation for you.

Anyway, you should be able to build the document (pdflatex blah.tex), even if you're missing a bibliography item. The corresponding references will just appear as question marks in the PDF.

Longish answered 16/4, 2009 at 21:57 Comment(0)
Q
2

Rerun latex to regenerate the aux file.

Have a look at this discussion for pointers to a bit more information. Basically, you may have taken your citation out of the .tex file, but it still exists in one of the derived files (aux, bbl, whatever...)

Quietude answered 16/4, 2009 at 20:26 Comment(0)
M
1

Check if your bib file has the extension .bib and not .tex. If it is .tex, just change it to .bib and that should do it. Once I changed it accidentally to tex, by adding some references, and saving it with the "save as" option, without specifying the bib extension. That's how it can happen all of a sudden.

Maunsell answered 23/7, 2012 at 19:33 Comment(0)
S
0

delete all your .aux and temporal files, re run with latex and then bibtex and then latex twice.

Smallsword answered 31/1, 2021 at 17:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.