Monday, January 7, 2013

TeX Directory Structure or Where to Install Packages?

If you are a regular TeX user, there are many good reasons to understand and exploit the TeX directory structure (TDS). Let me offer some:

  • You download a package from CTAN (or somewhere else). This could be a style file, for example. Is there some central place you could put it, so that it is in the "path" (so that you can avoid making multiple copies of the same style file in all your working directories)?
  • You make a bibliography style file to suit a journal's requirements (using custom-bib). Can you put this in the "same" central place?
  • You have a bibliography (bib) file with all your references. Can you put this in the path too? And can you do that without completely cluttering that central place?
  • You have an account that is administered by a university or department, and the TeX installation is common to all users. Can you make sure that the .sty, .bst, .bib files that we talked about above do not get wiped off, when the systems administrator decides to upgrade the TeX installation?

If you use TDS, the answer is yes. The good news is that this works independent of the OS platform.

The first thing is to find out where this place is. You can do that by simply typing the following in a terminal.

kpsewhich -var-value=TEXMFHOME

On my Mac this is ~/Library/texmf, and on my Linux desktop it is ~/texmf.

If such a directory does not already exist, you can create it (mkdir texmf) at the above location. You then make sub-directories. The important ones are:

bibtex directory
   - bst sub-directory (put bst files here)
   - bib sub-directory (put bib files here)
tex directory
   - latex sub-directory (put packages here)
doc directory
     put doc files from packages installed in the tex directory here.

You can make further sub-directories.

For example, you can make a "tools" directory within texmf/tex/latex/tools and put, for example, the tools package files here (tex and sty), and move the corresponding doc files to the texmf/doc folder.

In newer systems you don't even have to run texhash or mktexlsr to "update" the path if you do this.

No comments:

Post a Comment