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 have a .bib file called "A B C.bib" which is assigned to "A B C.tex". When I run .tex file and then .bib file I get the following error:

 White space in argument---line 18 of file A B C.aux
 : \bibdata{'A
 :             B C'}
I'm skipping whatever remains of this command
share|improve this question
2  
I don't think BibTeX supports files with spaces in their names. The control about spaces in the file name is built in BibTeX. –  egreg May 5 '13 at 15:36
    
@egreg Sorry but I didn't understand your response. What do you mean that control about spaces is built in BibTeX?? –  Naji May 5 '13 at 15:40
    
+ What should I do? –  Naji May 5 '13 at 15:42
    
That error message is issued by BibTeX, which doesn't accept file names with a space as legal .bib files. What can you do? Rename your .bib file omitting the spaces. –  egreg May 5 '13 at 15:43
1  
BibTeX inputs the .aux file you tell it to, which usually isn't the same name as the .bib file. If your TeX file is called naji.tex the .bib file can be anything, as long as it hasn't spaces in its name. –  egreg May 5 '13 at 15:47
show 3 more comments

2 Answers

up vote 6 down vote accepted

BibTeX doesn't accept spaces in the name of the bibliography file it inputs. So a file named A B C.bib is rejected.

It's by no means necessary that the .bib file has the same name as the LaTeX file; to the contrary, many people organize their big bibliography file and call that one for all their papers.

Example. The following is the file naji.tex:

\documentclass{article}
\begin{document}

\cite{x} \cite{y}

\bibliographystyle{plain}
\bibliography{najibibdatabase}

\end{document}

You process it by saying

pdflatex naji
bibtex naji
pdflatex naji
pdflatex naji

and it's BibTeX's job to read from naji.aux the line

\bibdata{najibibdatabase}

so it can open for reading the file najibibdatabase and extract from it the entries corresponding to the x and y keys.

There's no requirement that the argument to \bibliography is the same name as the main TeX file where it's given.

In any case it's best to avoid spaces in file names for all TeX-related documents.

share|improve this answer
    
I am actually doing it in texshop in Mac. I also did the same as you wrote but then when I run bibTeX(press bibTeX button in TeXshop) I get the following error: I couldn't open file name `Najibib.aux' –  Naji May 5 '13 at 16:06
    
I set the name of the tex as Naji.tex and the bib as Najibib.bib –  Naji May 5 '13 at 16:06
    
@Naji: in which window are you hitting the button? It should be the window with the tex file, not the bib file. –  Matthew Leingang May 5 '13 at 16:16
    
@MatthewLeingang I first hit the LaTeX button on .tex file, then press the bibTeX button on .bib file which I used to do for any other document(without spaces) but now I have this trouble when .bib and .tex does not have the same name! –  Naji May 5 '13 at 16:22
2  
@Naji You don't have to open the .bib file in TeXShop. Just choose "BibTeX" from the drop down menu and launch Command-T. –  egreg May 5 '13 at 17:55
add comment

If you are working on a mac or linux, you can use a symbolic link to your .bib file. At the command line, type ln -s <target> bib.bib to create a symbolic link between bib.bib and your actual .bib file. You can now use \bibliography{bib} in the .tex file.

share|improve this answer
    
The thing is I am not using Terminal to TeX my files, I use TeXshop itself. –  Naji May 5 '13 at 16:23
1  
@Naji: That's not really a problem, you only need the terminal to create the link once. –  T. Verron May 5 '13 at 16:24
    
But then I have to keep doing this link for every new tex file, right? :D –  Naji May 5 '13 at 16:26
1  
@Naji actually, no - you can copy the symbolic link to a new location once you've made it. –  Andy Clifton May 5 '13 at 16:28
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.