## LaTeX forum ⇒ BibTeX, biblatex and biber ⇒ Make addbibresource{} choose one out of many .bib

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
arstaer
Posts: 12
Joined: Sun Jun 17, 2012 5:56 am

### Make addbibresource{} choose one out of many .bib

Dear all,

Here is the issue, I plan to make
\addbibresource{}
to look for .bib files in different folders and choose the ones that are available without throwing errors if one of the bib files is not in the location specified.

Basically,
\addbibresource{Zotero2012.bib}   \addbibresource{T:/MYDOCS~1/MYBIBT~1/Zotero2012.bib}

Should skip the first one if it's not there and choose the second one if it's in that location and if it's in both locations, use both.

At the moment, if the first file is missing, but the 2nd one is present, the citations still don't get resolved.

That's to facilitate working with coauthors without uploading anything to the cloud.

Would appreciate any help!

Thank you,

AS

Tags:

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
You probably want something like

\IfFileExists{Zotero2012.bib}   {\addbibresource{Zotero2012.bib}}   {}\IfFileExists{T:/MYDOCS~1/MYBIBT~1/Zotero2012.bib}   {\addbibresource{T:/MYDOCS~1/MYBIBT~1/Zotero2012.bib}}   {}

Regards
site moderator & package author

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
BTW: if those two files contain the same bib data with the same cite keys I am pretty sure this will cause conflicts:

\documentclass{article}\usepackage{filecontents}\begin{filecontents}{\jobname.bib}@article{test,   author = {me} ,   title = {test}}@article{test,   author = {also me} ,   title = {also a test}}\end{filecontents} \usepackage{biblatex}\addbibresource{\jobname.bib} \begin{document} foo \cite{test} \end{document}

gives

Running Biber' on test' with biber test''...WARN - Duplicate entry key: 'test' in file 'test.bib', skipping ......INFO - WARNINGS: 1
site moderator & package author

arstaer
Posts: 12
Joined: Sun Jun 17, 2012 5:56 am

I tried to use this but then I get
! LaTeX Error: Missing \begin{document}. See the LaTeX manual or LaTeX Companion for explanation.Type  H <return>  for immediate help.  ...                                               l.84

I tried to debug it but I don't know where the problems lie.

I created an MWE:
  \documentclass[12pt]{article}    \usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}      \IfFileExists{Zotero2012.bib}     {\addbibresource{Zotero2012.bib}}      \IfFileExists{T:/MYDOCS~1/MYBIBT~1/Zotero2012.bib}     {\addbibresource{T:/MYDOCS~1/MYBIBT~1/Zotero2012.bib}} \begin{document}       Furthermore, the NAV-price arbitrage...   \end{document}

And it still gives me the missing document error.

! LaTeX Error: Missing \begin{document}.

Thank you!

AS

Edit: The problem is in the \IfFileExists{T:/MYDOCS~1/MYBIBT~1/Zotero2012.bib}, is there a way to make this work? Spent hours, and still haven't been able to find a solution. Any help would be greatly appreciated as the submission deadline draws near.

Edit 2: Seems I found a way!
\IfFileExists{T:/MYDOCS\string~1/MYBIBT\string~1/Zotero2012.bib} {\addbibresource{T:/MYDOCS\string~1/MYBIBT\string~1/Zotero2012.bib}}

now no missing begin document errors at compiling

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
\IfFileExists has three arguments: one for the file name,one for the true branch and one for the false branch. Your example misses the third (probably empty) argument.
site moderator & package author