0

Can someone please give a straightforward guide to adding .bib resources with relative and full file paths?

On Windows 8.1 I have a file path with a space that I could not figure out how to escape. So I followed a suggestion to use a relative path (one directory up) with ..\file.bib). This also did not work. I was only able to use the bib file by copying it to the same directory as the .tex file.

So please explain:

  • First--what is the proper syntax for file paths within \addbibresource{}?
  • Second--what changes have to be made for Windows?
  • Third--How do you escape spaces? (Yes, I want to use file structures with spaces in their names.)
0

2 Answers 2

1

Re 1

File paths should be given with / as path separator to avoid issues with \ being interpreted as starting a control sequence.

Both absolute an relative paths can be given as usual (if you use / as path separator)

\addbibresource{D:/Moritz/Documents/TeX/examples/relpath/testbibfile.bib}
\addbibresource{../testbibfile.bib}

Relative paths are resolved relative to the working directory of the Biber call (which should usually be the directory where the .bcf resides, which should usually be the same directory as the main .tex file of your document/project).

Re 2

Use / as path separator, not the standard Windows \.

This is an annoyance because you can't just copy and paste paths, but at least it allows you to use macros like this ...

\newcommand\myfolder{myfolder}
\addbibresource{../\myfolder/testbibfile.bib}

(not that I would recommend that sort of thing in general).

Re 3

There is a bug in Biber 2.14 that essentially means that Biber can not resolve paths with spaces in them. This will be resolved in the next Biber version, but until then you need to avoid spaces. (On Linux systems one space in the file name should work, but on Windows even a single space will cause issues). See biber error from spaces in paths using addbibresource.

There is only one exception: Files found via kpsewhich may be located in paths with spaces in them. On my (Windows) system for example biblatex-examples.bib will be found if I say

\addbibresource{biblatex-examples.bib}

even though its actual path contains two spaces (as shown in the Biber log)

INFO - Found BibTeX data source 'C:/Program Files/MiKTeX 2.9/bibtex/bib/biblatex/biblatex-examples.bib'
0

Since your 3 questions were explained above, I'll just tell you how I did my workaround in this case (it's simple):

1) use Windows sharing tool and give the right permissions to your bib files folder;

2) everywhere you supposed to pass the path with spaces, just pass "\\localhost\MyBibFolder". In my case (MiKTeX), I did it in MiKTex Console -> Settings -> Directories (don't forget to refresh file name database after entering the path);

3) Use \addbibresource passing just the file name (e.g. \addbibresource{testbibfile.bib})

You must log in to answer this question.

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