Sign up ×
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

2 Answers 2

up vote 20 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

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

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.
http://tex.stackexchange.com/questions/8332/undefined-citation-warnings?answertab=oldest
tex.stackexchange.com
crawl=CC-MAIN-2015-40
79681
application/http; msgtype=response
sha1:IYXMBUZ3N53AY4MDVA574JN4PEFHI3HM
<urn:uuid:34bc00d9-f1c8-4056-bdc9-7cd4cc102f99>
2015-10-05T13:23:34Z
104.16.16.128
sha1:CBFK7REN2VJ56KZXHENPOG7KKS2KSCQT
<urn:uuid:c7a7efa0-4b85-4090-bcae-1ff7826fbaec>
http://tex.stackexchange.com/questions/8332/undefined-citation-warnings?answertab=oldest
length
response
<urn:uuid:a570c69e-15c0-4921-b75d-0a9dac36d579>
robots: classic
hostname: ip-10-137-6-227.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-40
operator: CommonCrawl Admin
description: Wide crawl of the web for September 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf