8

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.

A.Ellett
  • 50,533
  • Have you run texhash to update your TDS? – Werner Jun 19 '13 at 02:18
  • What is my TDS? – A.Ellett Jun 19 '13 at 02:19
  • Sorry, try mktexlsr; I'm not sure texhash is still supported/active. TDS refers to your TeX Directory Structure. – Werner Jun 19 '13 at 02:20
  • Now things are working. Not sure why. – A.Ellett Jun 19 '13 at 02:28
  • Did you run mktexlsr or texhash? – Werner Jun 19 '13 at 02:33
  • I did both. Most recently mktexlsr. – A.Ellett Jun 19 '13 at 02:34
  • mktexlsr (perhaps formerly known as texhash, not sure), is a procedure that updates a reference list to your TDS. This reference list is searched when looking for packages that are not located in the root folder where your source document resides. – Werner Jun 19 '13 at 02:39
  • One advantage (which should also be true on OSX, I suppose) of using the standard location for TEXMFHOME is that you don't need to use mktexlsr when you add a new file. I'm kind of surprised, in fact, that there isn't a way to make your new location automatically searched just as ~/texmf (or, I think, ~/Library/texmf) is. – jon Jun 19 '13 at 03:37
  • 1
    Another idea: symlink your directory. I think you can use this command on OSX: ln -st ~/texmf/tex/latex/ ~/private/texmf. (Note: I assume these are personal latex files.) – jon Jun 19 '13 at 04:13
  • @jon: Isn't TEXMFHOME, as opposed to TEXMFLOCAL and TEXMFDIST, usually configured to not use a ls-R database anyway? I seem to recall this used to be the case in TeXLive. – Ulrich Schwarz Jun 19 '13 at 06:24
  • I keep all the packages that I write in a separate directory and then add symbolic links to them in my ~/Library/texmf – Alan Munn Jun 19 '13 at 11:31
  • @AlanMunn isn't that quite annoying as you will need to create a new symlink for every file that you add, rather than adding your own directory once? – Tom Nov 18 '13 at 15:16
  • @Tom I guess it's a matter of taste. I like my local texmf directory to accurately reflect what's in it, and so separate links to each package directory (not each file) is more transparent than a single link to the other directory. – Alan Munn Nov 18 '13 at 15:22

1 Answers1

9

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.

egreg
  • 1,121,712
  • 1
    This could be problematic. http://www.tug.org/pipermail/tex-live/2012-July/032005.html and the rest of the documentation in this thread. – Ulrike Fischer Jun 19 '13 at 09:27
  • @UlrikeFischer I read it, but I don't see how this might cause problems. In my test, files are found both in ~/private/texmf and ~/Library/texmf trees. – egreg Jun 19 '13 at 09:33
  • 1
    Finding files is not the problem. The question is if some scripts expect texmfhome to expand to a single directory (like the problem starting the thread where updmap expected texmflocal to contain only one directory). It is quite possible that it works without problems (as there has been a bit pressure due to some discussions about "how to add more trees like in miktex). – Ulrike Fischer Jun 19 '13 at 10:08