I use Mendeley to organise citations. It exports a .bib file automatically to a folder on my Mac.

I also have another .bib file that I use for other citations not stored in Mendeley (websites mostly). This file is stored in a folder containing all my LaTeX projects in separate folders.

The reason that the .bib files are stored separate of the LaTeX project is that multiple projects use the same citations and this way I only have to maintain one .bib file (the other one is maintained by Mendeley).

Inspired by the question on VCS I added my current LaTeX project to bitbucket.org using git. It is a directory that contains my .tex files and images, not the .bib file.

In my main.tex I include the two bibliographies as follows:


My goal now is to make the repository self-contained, so that someone can just clone it and compile the LaTeX document.

As my .bib files are not in the repo, how can I achieve this?
Symlinks are not an option as git does not follow symlinks anymore.

  • Sorry, but this sounds like a Git/VCS question not a (La)TeX one: looks off-topic to me. – Joseph Wright Mar 14 '14 at 14:28
  • Maybe the bibexport script can be what you want – egreg Mar 14 '14 at 14:34
  • @egreg thanks for the suggestion. Just tried bibexport and unfortunately it doesn't work well. It doesn't recognize some citation types like electronic or misc. This result in a .bib file that is broken and needs to be manually fixed. – Saaru Lindestøkke Mar 14 '14 at 15:04
  • You can modify export.bst to add fields, see the documentation; for new entries like @electronic, I believe it's sufficient to add a FUNCTION at the end, similar to the existing ones. Maybe you can look also to bibextract.sh – egreg Mar 14 '14 at 15:09

I ended switching from natbib to biblatex+biber. The latter supports the \addbibresources[location=remote] command that can use a link to a .bib file as an input.




Now a check is carried out if the local .bib files are present. If so, it just uses them, if not it downloads the .bib files from Dropbox where I've made them publicly available (the links shown here are not the actual links).


I solved the issue by copying the bib into the local folder using a make-file (being called by latexmk). That way you also have the right version in your repo. One of the main issues I had with Mendely was that the order of the entries changes every time the file is written. So I extended the Makefile to run it through bibtool. My Makefile is a bit more complex, but for you it would boil down to:

        cat $< | bibtool -o $@ -r ./bib.rsc

And the bib.rsc looks like

resource {sort_fld.rsc}
sort                     = on
preserve.keys            = on
preserve.key.case        = on

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.