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.

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!

share|improve this question
    
Welcome to TeX.SX! You can have a look on our starter guide to familiarize yourself further with our format. –  mafp Jun 21 '13 at 15:07
4  
You can't use backslashes in the path name, as TeX sees them as macros. It is usually better to put the bibliography file in a place where BibTeX will find it by itself, and just use \bibliography{bibfile}. Note that on Windows even slashes work, as far as BibTeX is concerned. –  mafp Jun 21 '13 at 15:17
    
Thank you very much for your reply. However, I don't know where I could put the file so BibTex find it by itself. I'll google it. –  Josh Jun 21 '13 at 16:39
    
There is an environment variable BIBINPUTS that can specify paths where BibTeX should look for bib files. –  mafp Jun 21 '13 at 16:55
    
@mapf see my answer about BIBINPUTS –  karlkoeller Jun 21 '13 at 17:25
show 1 more comment

2 Answers

up vote 8 down vote accepted

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}
share|improve this answer
    
I've already tried putting the bibTeX file into the current directory of my TeX file. It worked perfectly. Thank you for your reply. –  Josh Jun 21 '13 at 17:39
    
I don't use MikTeX, so what goes wrong with BIBINPUTS there? –  mafp Jun 21 '13 at 20:46
    
@mafp You can see it from my answer. MiKTeX uses C:/Program Files/MiKTeX 2.9/bibtex/bib/mslapa/bibdata.bib instead of C:/filelocation/bibdata.bib if you don't specify --include-directory="C:/filelocation" in the command line. This is the (strange) way MiKTeX behaves in regards of BIBINPUTS. –  karlkoeller Jun 21 '13 at 20:53
add comment

As @mafp says in the comment, you cannot use \ in the path name. Instead, change \ to / should solve the problem.

share|improve this answer
    
Thank you! This actually solved the problem! –  Josh Jun 21 '13 at 16:40
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.