[Tex/LaTex] Setting environment variables for latex and bibtex in .bashrc

bibtexpaths

Possible Duplicate:
.bib library file in a different directory, how to use? (Mendeley centralised .bib file)

I recently started using TeX to write journal articles. I use TeX Live version 2009-10 on a laptop running Ubuntu 10.10 (64-bit). I edit and compile the tex files using vim and vim-latexsuite.

Currently for each journal article I have all associated tex, bib, eps, etc. files in individual folders. I would like to simplify my life a bit and have a dedicated folder containing a "master" bib file – And maybe another folder for my custom style files.

My problem is that can't figure out how I should define the PATH, and other environment variables in my .bashrc file to find the necessary support files (e.g., the .bib file). Which variables do I need to set? PATH? MANPATH? TEXINPUTS? BIBINPUTS?

Best Answer

Short version: I would put the BIB files to ~/texmf/bibtex/bib/myfiles/myfile.bib and style files to ~/texmf/tex/latex/myfiles/myfile.sty for example.

Long version: try

kpsexpand '$TEXMFHOME'
kpsexpand '$TEXMFLOCAL'

which will show you where you can put your local files, so that TeX will find them out-of-the-box. By default this is ~/texmf (for your personal files) and /usr/local/texlive/texmf-local (for system-wide additions). Inside that tree you need to follow TDS standard. For BIB files that would be:

BIBINPUTS = .;$TEXMF/bibtex/bib//

That is default value in TeX Live 2011 at least. You may check texmf.cnf on your system if the value is any different, or try to run one of the following commands:

kpsexpand '$BIBINPUTS'
kpsewhich --expand-path '$BIBINPUTS'

This will tell you where BibTeX searches for BIB files.

If you need those files only for a couple of projects and/or don't want to pollute your home folder, the cheapest trick is to create a TDS structure anywhere on the disk and only set TEXMFHOME to point to that location.

Setting TEXINPUTS and BIBINPUTS is not recommended. Setting PATH only helps you to find binaries like pdftex, but then pdftex should be able to find texmf.cnf and that file contains enough information to find everything else. You can override any setting from texmf.cnf with environmental variables, but I would suggest you to place the files to locations where TeX expects them as opposed to setting variables.

Related Question