27

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}
orome
  • 10,459
  • @MarcoDaniel: Yes, corrected. The path question remains. – orome Mar 02 '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 02 '12 at 20:04
  • @DavidCarlisle: That doesn't work for me (OS X; MacTeX). – orome Mar 02 '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 02 '12 at 20:22
  • @DavidCarlisle: FWIW, the ~ works for me (e.g. in paths with no spaces). – orome Mar 02 '12 at 20:28
  • 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 02 '12 at 20:46
  • @raxacoricofallapatorius -- of course, I was just pointing out that you will not be able to use biblatex (full path or not) without updating the way you include your bibliography file. (Which is why I wrote it as a comment rather than an answer.) Incidentally, I regularly specify a full path in the form of /home/jon/academic/bibliography.bib --- just with no spaces. – jon Mar 03 '12 at 20:59

3 Answers3

18

(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

Frédéric
  • 11,087
  • 3
  • 37
  • 43
  • 1
    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 02 '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 03 '12 at 02:39
  • Pretty much as stated: see MWE above. – orome Mar 03 '12 at 04: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 03 '12 at 04:44
  • You'll need the latest tuft-common.def (3.5.2) to get it to compile. – orome Mar 03 '12 at 05:06
  • 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 03 '12 at 05:36
6

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.

  • Some notes that I had to do to make it work for me:
    1. If a short path does not exist, you need to create one: https://manjusullad.wordpress.com/2016/01/06/how-can-i-find-create-short-path-for-windows-folders-directories/
    2. When using the short path, the "~" has to be specified as a string (eg., use "MYDOCS\string~1" instead of "MYDOCS~1" in the path in latex)
    – Esteban Mar 13 '20 at 14:50
0

I have a feeling that this specific issue is still unresolved. I use Windows 10 and I need to keep everything on One Drive. The path to my bibliography is: D:\One Drive\bibtex\biblio.bib.

No matter how I try, the suggested solutions do not work for me. Solution with D:\One~1\bibtex\biblio.bib does not work nor is embracing the path in double quotes. I am getting error when using biber that it could not locate the file.

I found a solution by use of wild card as: D:\One*\bibtex\biblio.bib This however messes up the quick access with tree view in WinEdt - Can't access the file with the format of the path, which I think is no surprise.

I appreciate your help!

Cheers, Piotr

  • I know spaces used to be an issue with older versions of Biber. But I just successfully compiled a document referring to a .bib file with a space in the folder name (both with relative and absolute paths) with Biber 3.16, so I'd have thought this should work if it is only about the file path. Do you have the newest version of Biber? – moewe Jan 11 '21 at 21:19
  • Thank you @moewe. I have updated to texlive2020 and it seems that they do not provide biber version newer than 2.16. Probably will have to install it manually. – Piotr Ptak Jan 14 '21 at 07:56