[Tex/LaTex] Undefined control sequence while using bib file for References

bibliographiesbibtexerrorsmiktextexmaker

I'm using TexMaker, if it helps. I also have TeXnicCenter and TexWorks.

The tex file is the following:

\documentclass[11pt]{book}  
\begin{document}  
(...)  
\bibliographystyle{unrst}  
\bibliography{C:\filelocation\bibfile}  
\end{document}

This produces an 'Undefined control sequence' error… How could I fix it?

Any help will be appreciated!

Best Answer

Given that you've found the source of your error, I'll try to explain you where to put your bibliography file so to let BibTeX find your bibliography.

  1. Put your bibfile.bib in the same directory where your .tex file is.

  2. Leave your bibfile.bib in the directory "C:\filelocation" and call BibTeX in this way (assuming that your .tex file is test.tex)

    bibtex --include-directory="C:/filelocation" test

In both cases change the offending line:

\bibliography{C:\filelocation\bibfile}

to

\bibliography{bibfile}

Note that the second way works with MiKTeX only (it doesn't with TeX Live).

Unfortunately, using the BIBINPUTS environmental variable to set extra paths where to search for .bib files (as suggested by @mapf) works bad with MiKTeX, so it is better don't follow that way. This because MiKTeX has a strange manner to manage variables like BIBINPUTS. In fact, the search order is:

  1. The current directory.

  2. The directory specified with --include-directory command-line switch.

  3. Directories in the MiKTeX root folder

  4. Directories specified in BIBINPUTS variable

In your case, with Complete MiKTeX installed, if you run kpsewhich bibdata.bib you will get:

C:/Program Files/MiKTeX 2.9/bibtex/bib/mslapa/bibdata.bib

(or something similar) which is the file used by MiKTeX even if you set:

BIBINPUTS=.;C:/filelocation;

ADDENDUM

Just for completeness, I forgot to mention this obvious case:

  1. Put your bibfile.bib in a subdirectory of your .tex file, let's say biblio.

In this case, BibTeX finds it if you write

\bibliography{biblio/bibfile}