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}
8
  • @MarcoDaniel: Yes, corrected. The path question remains.
    – orome
    Mar 2, 2012 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 "..." Mar 2, 2012 at 20:04
  • @DavidCarlisle: That doesn't work for me (OS X; MacTeX).
    – orome
    Mar 2, 2012 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) Mar 2, 2012 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, 2012 at 20:46

3 Answers 3

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

6
  • 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 2, 2012 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, 2012 at 2:39
  • Pretty much as stated: see MWE above.
    – orome
    Mar 3, 2012 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, 2012 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, 2012 at 5: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.

1
  • 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: manjusullad.wordpress.com/2016/01/06/… 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, 2020 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

2
  • 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, 2021 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, 2021 at 7:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .