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.

When I compile my document I get warnings of the form:

Package natbib Warning: Citation `xxxxx' on page y undefined on input line 
z.

This problem does fix itself eventually when the compiler reached my bibliography.bib file but is there a way I can prevent them from occurring in the first place?

share|improve this question
add comment

2 Answers 2

up vote 17 down vote accepted

Getting citations and references right always requires multiple runs of latex. The normal procedure is the following

latex <file>
bibtex <file>
latex <file>
latex <file>

The first compile finds all the cite commands and makes a list of them in the .aux file, and takes note of the bibliography style. No citations are resolved in your document yet.

Then bibtex processes the aux file and using the bibliography style, and the list of citations creates a .bbl file which contains the bibliography. No citations are resolved yet here either.

The next latex compile doesn't resolve the references either, but reads the .bbl file and keeps track of the citations.

Finally the last latex compile resolves all the references.

The warnings you receive are normal, and should really only be paid attention to after the last latex compilation in the steps above.

There are various scripts that automate some of these procedures so that you don't forget to do the multiple latex runs; one is latexmk and another is rubber.

Many text editors have access to these in some simple way, so before thinking about installing them you should find out if your editor already has a way to use them.

share|improve this answer
4  
That is not always sufficient. It's possible for a reference to move around after every compile. In the worst case, the reference will always be wrong, no matter how many times you compile it. –  TH. Jan 5 '11 at 20:53
    
Doesn't work. Still got the same errors. –  user19502 Jun 30 '13 at 23:44
    
@user19502 Are you getting exactly the same warning as in the question? Are you sure you don't have a typo in the citation key? –  Alan Munn Jun 30 '13 at 23:48
    
I might have had some errors, I don't have them now. For the past five hours I've been trying to make the bibliography in my own thesis look the way I want, not the way Latex wants –  user19502 Jul 1 '13 at 0:36
    
@user19502 Well that's a different question. There are lots of bibliography questions on the site, and most of the common styles are available. Hopefully the way you want it is something well accepted in your field. If so, then we should be able to solve your problem. But that sounds like a separate question. –  Alan Munn Jul 1 '13 at 0:47
add comment

Not sure if it relates directly to your problem but I kept on getting bibtex key is undefined errors in Texlipse even though the bibliography compiled fine.

I manage my bibliography using Jabref. What happens is that sometimes I would accidentally create a new empty entry in Jabref (e.g. click on add new entry, make no changes, and hit enter = empty entry). This is what generated the error in Texlipse. Delete these empty entries and everything will be fine.

share|improve this answer
add comment

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.