[Tex/LaTex] LaTeX cannot find the personal packages

macmactexpackagestexmf

I'm venturing into writing my own packages, but LaTeX is not finding them.

I working on a iMac OS X, but I don't want to use TEXMFHOME=~/Library/texmf. I would like to put my packages in a different directory: for the sake of this post let's call it ~/private/texmf.

My TEXINPUTS is set as TEXINPUTS=.:~/private/texmf//: and works perfectly well for standard .tex files. But when I place a new .sty file in these directories, LaTeX complains that they can't be found.

I've tried numerous things. The two most notable are:

  1. Setting TEXMFHOME=~/private/texmf:~Library/texmf
  2. Setting TEXMFHOME=~/private/texmf

Both times, I've entered ~/private/texmf and run sudo texhash to update everything (I've never had to do this before). I've moved to the directory in which my packages are located ~/private/texmf/tex/latex/packages/ and called texhash again. All to no avail.

I've search the web and this site for clues about what to do:

  1. Change TEXMFHOME per-user

  2. Where do I place my own .sty files, to make them available to all my .tex files?

  3. How to access style files in texlive-publishers from Kile

    What's mentioned above is what seemed to be suggested at various different sites. Nothing's working.

Help.

Best Answer

The location of the "private tree" is normally, with MacTeX,

~/Library/texmf

to which the (pseudo)variable TEXMFHOME points:

> kpsewhich --var-value TEXMFHOME
/Users/<user>/Library/texmf

(I only masked my real user name on this machine). If you try

> less $(kpsewhich texmf.cnf)

you'll get on your screen something like

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
TEXMFHOME = ~/Library/texmf
TEXMFVAR = ~/Library/texlive/2013/texmf-var
TEXMFCONFIG = ~/Library/texlive/2013/texmf-config
/usr/local/texlive/2013/texmf.cnf (END)

The last line doesn't belong to the file, it just shows its location. This file is the top level texmf.cnf so the first to be read in when a TeX program is launched; the system is set up so that no variable is clobbered when other texmf.cnf files are input.

Thus what you have to do is simply editing that file

sudo nano $(kpsewhich texmf.cnf)

(use whatever editor you prefer instead of nano); for instance, you might want to set

TEXMFHOME=~/private/texmf:~Library/texmf

I tested it and files are found in both locations (precedence to ~/private/texmf). You don't need to run texhash or mktexlsr after adding files to the private tree or trees. However, you have to properly create a structure in the tree; a file such as wonderfulpackage.sty can be found by LaTeX only if it's stored as

~/private/texmf/tex/latex/wonderfulpackage/wonderfulpackage.sty

(the last subdivision, that is, the directory wonderfulpackage) is optional, but its usage is recommended for later maintenance. If you put the file just at ~/private/texmf it will not be found by LaTeX.

Related Question