Question mark or bold citation key instead of citation number
Since this question comes up so often, I thought I'd try to supplement ArTourter's correct answer with a more general comment.
What does a question mark mean
It means that somewhere along the line the combination of LaTeX and BibTeX has failed to find and format the citation data you need for the citation: LaTeX can see you want to cite something, but doesn't know how to do so.
Missing citations show up differently in biblatex
If you are using biblatex
you will not see a question mark, but instead you will see your citation key in bold. For example, if you have an item in your .bib
file with the key Jones1999
you will see Jones1999 in your PDF.
How does this all work
To work out what's happening, you need to understand how the process is (supposed to) work. Imagine LaTeX and BibTeX as two separate people. LaTeX is a typesetter. BibTeX is an archivist. Roughly the process is supposed to run as follows:
LaTeX (the typesetter) reads the manuscript through and gives three pieces of information to BibTeX (the archivist): a list of the references that need to be cited, extracted from the
\cite
commands; a note of a file where those references can be found, extracted from the\bibliography
command; a note of the sort of formatting required, extracted from the\bibliographystyle
command.BibTeX then goes off, looks up the data in the file it has been told to read, consults a file that tells it how to format the data, and generates a new file containing that data in a form that has been organised so that LaTeX can use it (the
.bbl
file).LaTeX then has to take that data and typeset the document - and may indeed need more than one 'run' to do so properly (because there may be internal relationships within the data, or with the rest of the manuscript, which BibTeX neither knows or cares about, but which matter for typesetting.
Your question-mark tells you that something has gone wrong with this process.
More biblatex
and biber
notes
If you are using
biblatex
, the style information is located in the options passed to the to thebiblatex
package, and the raw data is in the\addbibresource
command.If you are using
biber
, the stage described as BibTeX in this answer is generally replaced with a different, and more cunning, archivist, Biber.
What to do
The first thing to do is to make sure that you have actually gone through the whole process at least once: that is why, to deal with any new citation, you will always need at least a LaTeX run (to prepare the information that needs to be handed to BibTeX), one BibTeX run, and one or more subsequent LaTeX runs. So first, make sure you have done that. Please notice, that latex
and bibtex
/biber
need to be run on your main file (without the file ending). In other words, the basename of your main file: you do not run any commands on the .bib
file.
latex MainFile
bibtex MainFile
latex MainFile
latex MainFile
If you still have problems, then something has gone wrong somewhere. And it's nearly always something about the flow of information.
Your first port of call is the BibTeX log (.blg
) file. That will usually give you the information you need to diagnose the problem. So open that file (which will be called blah.blg
where 'blah' is the name of your source file).
In a roughly logical order:
BibTeX did not find the style file. That's the file that tells it how to format references. In this case you will have an error, and BibTeX will complain
I couldn't open the style file badstyle.bst
. If you are trying to use a standard style, that's almost certainly because you have not spelled the style correctly in your\bibliographystyle
command - so go and check that. If you are trying to use a non-standard style, it's probably because you've put it somewhere TeX can't find it. (For testing purposes, I find, it's wise to remember that it will always be found if it's in the same directory as your source file; but if you are installing using the facilities of your TeX system -- as an inexperienced person should be - you are unlikely to get that problem.)BibTeX did not find the database file. That's the
.bib
file containing the data. In that case the log file will sayI couldn't open database file badfile.bib
, and will then warn you that it didn't find database files. The cure is the same: go back and check you have spelled the filename correctly, and that it is somewhere TeX can find it (if in doubt, put it in the folder with your source file).BibTeX found the file, but it doesn't contain citation data for the thing you are trying cite. Now you will just get, in the log-file:
Warning--I didn't find a database entry for "yourcitation"
. That's what happened to you. You might think that you should have got a type 2 error: but you didn't because as it happens there is a file calledmybib.bib
hanging around on the system (askpsewhich mybib.bib
will reveal) -- so BibTeX found where it was supposed to look, but couldn't find the data it needed there. But essentially the order of diagnosis is the same: check you have the right file name in your\bibliography
command. If that's all right, then there is something wrong with that file, or with your citation command. The most likely error here is that you've either forgotten to include the data in your.bib
file, or you have more than one.bib
file that you use and you've sent BibTeX to the wrong one, or you've mis-spelled the citation label (e.g. you've done\cite{nobdoy06}
for\cite{nobody06}
.There's something wrong with the formatting of your entry in the
.bib
file. That's not uncommon: it's easy (for instance) to forget a comma. In that case you should have errors from BibTeX, and in particular something likeI was expecting a ',' or a '}'
and you will be told that it wasskipping whatever remains of this entry
. Whether that actually stops any citation being produced may depend on the error; I think BibTeX usually manages to produce something -- butbiblatex
can get totally stumped. Anyway, check and correct the particular entry.
biblatex
and biber
notes
If you are using biblatex
, then generally you will also be using the Biber program instead of BibTeX program to process your bibliography, but the same general principles apply. Hence the compilation sequence becomes
latex MainFile
biber MainFile
latex MainFile
Summary
The order of diagnosis is as follows:
Have I run LaTex, BibTeX (or Biber), LaTeX, LaTeX?
Look at the
.blg
file, which will help mightily in answering the following questions.Has BibTeX/Biber found my style file? (Check whether you have a valid
\bibliographystyle
command and that there is a.bst
with the same name where it can be found.)Has BibTeX/Biber found my database? (Check the
\bibliography
names it correctly and it is able to be found.)Has it found the right database?
Does the database contain an entry which matches the citation I have actually typed?
Is that entry valid?
Finally: When you have changed something, don't forget that you will need to go through the same LaTeX -- BibTeX (or Biber) -- LaTeX -- LaTeX run all over again to get it straight. (That's not actually quite true: but until you have more of a feel for the process it's a safe assumption to make.)
The syntax for the \bibliography{}
command is \bibliography{file1,file2,...}
in your case you seem to be calling a file called mybib
when your bib file is in fact Bib
.
Also note that bibtex file should have the .bib
extension. the .bbl
file will be created by bibtex.
You should therefore rename your bibliography file mybib.bib
and get rid of the extra {}
in the \bibliography{mybib}{}
call, and then recompile. This should fix your problem.