24

I'm trying to get biblatex to see where I have my .bib file located, but I have a space in the path to the file:

\addbibresource{~/Documents/My Project/TheBib.bib}

How do I specify a full path that includes a space? Is there a way to specify a relative path?


M(Not)WE, as requested:

\documentclass[nobib]{tufte-handout}

\usepackage{hyphenat} 
\usepackage[backend=bibtex, natbib=true, citestyle=verbose]{biblatex}
\addbibresource{~/Documents/Projects/NoSpaces/Sources.bib} % Works
%\addbibresource{~/Documents/Projects/Some Spaces/Sources.bib} % Fails
%\addbibresource{"~/Documents/Projects/Some Spaces/Sources.bib"} % Fails

\begin{document}

Test.\cite{CiteKey}

\printbibliography 

\end{document}
  • @MarcoDaniel: Yes, corrected. The path question remains. – orome Mar 2 '12 at 19:52
  • 1
    the file paths accepted depend on the tex implementation but I believe web2c based ones will accept paths with spaces if you surround them with "..." – David Carlisle Mar 2 '12 at 20:04
  • @DavidCarlisle: That doesn't work for me (OS X; MacTeX). – orome Mar 2 '12 at 20:12
  • 1
    sorry I know nothing about macs. Also you the ~ may cause problems as it expands to non breakable space normally, you might need \string~ (or you might not if biblatex quotes it automatically, not sure) – David Carlisle Mar 2 '12 at 20:22
  • 1
    Can't help with spaces in names as I learned to avoid them many years ago, but you should now use \addbibresource{TheBib.bib} for recent versions of biblatex. – jon Mar 2 '12 at 20:46
16

(Note: I'm working on a mac)

There are two problems with the path you specify:

1- The space: simply enclose the path in double quotes (")

2- The ~. TeX won't treat it as a substitute for /Users/You. You might want to consider using relative paths: a) ./indicates the current working directory b) ../ moves one step up the directory tree.

So if your file structure is as

My project
       main.tex
       bib --> TheBib.bib

You need only use ./bib/TheBib.bib. If however your file structure is something like

My project
       tex --> main.tex
       bib --> TheBib.bib

You use ../bib/TheBib.bib

And so on

  • Are you sure about that? The ~ works fine for me (to a location with no spaces in the path); ./ never works (with or without quotes); quotes don't help with spaces. – orome Mar 2 '12 at 23:55
  • I just tried everything again. The ~ does not work for me. Can you add a M(Not)WE. Maybe there is something in your file I or others can see. – Frédéric Mar 3 '12 at 2:39
  • Pretty much as stated: see MWE above. – orome Mar 3 '12 at 4:16
  • I just tried your example, with the same file structure and names. The problem I'm having is from the documentclass. When I use article, there is no problem: all 3 different addbibresource calls work. With the tufte-handout, it doesn't compile when I include all the bib stuff. – Frédéric Mar 3 '12 at 4:44
  • 1
    Obtained the latest tuft-comme.def. Everything compiles correctly, with ~and also paths with spaces. I cannot see what is causing your problem. – Frédéric Mar 3 '12 at 5:36
5

This might be helpful for Windows people,

Found this on http://osdir.com/ml/tex.miktex/2005-07/msg00022.html and all credit should go to them,

Use command prompt and MSDOS dir /x command in each parent folder of the folder with "spaces" to extract MSDOS 8.3 compliant names. The final path would look something like this,

normal Windows path, "T:/My Docs/MyBibTeXFiles/Zotero2012.bib"

With MSDOS names, "T:/MYDOCS~1/MyBibTeXFiles/Zotero2012.bib"

finally in .tex, \addbibresource{T:/MYDOCS~1/MyBibTeXFiles/Zotero2012.bib}

Don't forget to delete previous .aux file before you bibtex the .tex with this new folder. Worked great in MikTex in Win 7 here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.