Before proposing a procedure (rather newbies oriented), let's list the numerous ways to fail (more informed oriented) :
- stupid but still time consuming, error in spelling : test with a file named example.sty rather than with CMathLuaTeX.sty, or may be it was CmathLuaTeX.sty or maybe CmathLuaTex.sty ...
- $TEXMFHOME not in the $TEXMF or $TEXMFDBS list of directories (check
with
kpsewhich -var-value=TEXMF
or kpsewhich -var-value=TEXMFDBS
)
- errors with !!$TEXMFHOME instead of $TEXMFHOME in $TEXMF
- modifications done in the default texmf.cnf configuration file, wiped out by an update
- wrong location of the .sty file (not in the $TEXMFHOME/tex hierarchy)
- when using searches directly on the disk, presence of a ls-R file in the $TEXMFHOME directory that blocks the search on the disk (described in the kpathsea manual, experienced sometimes)
- when using searches directly on the disk with a symbolic link pointing to the actual directory of the .sty file : symbolic link in a directory with no subdirectory not taken into account
- when using searches with index ls-R files : ls-R file absent, outdated, misplaced (not in the $TEXMFHOME directory)
- custom texmf.cnf file to override the default texmf.cnf file in a wrong directory (for instance in the place recommended in the comments of the default texmf.cnf file !)
I had at least three of these bugs ...
Here is a procedure that should avoid all these pitfalls :
- Type
kpsewhich -var-value=$TEXMFHOME
to know where the texmf user trees should go (example : /home/ad/texmf)
- Create (if non existent) a subdirectory of the $TEXMFHOME directory named "tex" (for instance /home/ad/texmf/tex) and subdirectories like /home/ad/texmf/tex/latex or /home/ad/texmf/tex/mystuff
- Include in the $TEXMFHOME/tex hierarchy your .sty or .cls file, or a symbolic link to a hierarchy containing them.
We now need to inform kpathsea to search in $TEXMFHOME :
kpsewhich -var-value=TEXMFCNF
will give the list of directories where kpathsea looks for config texmf.cnf files. The order is meaningful : the leftmost directories are examined first and override the following files in case a variable is already defined. In the last directory of the list lies the default texmf.cnf file. In one of the directories before the last (usually the next to the last), create a new texmf.cnf if none exists. You may need administrator's rights, depending on the location of the directory. We will use this file to modify the definition of either the $TEXMF or $TEXMFDBS variables, depending on the type of kpathsea search we want : a) directly on the disk or b) based on ls-R index files. To avoid spelling error, the best is to copy the default values of the $TEXMF or $TEXMFDBS variables from the default texmf.cnf file (in the last directory of the former list of directories ).
- a) search on the disk : in the new texmf.cnf add "$TEXMFHOME" to the list found in the default texmf.cnf file for the variable $TEXMF ; example :
TEXMF = {$TEXMFCONFIG,$TEXMFVAR,$TEXMFSYSCONFIG,!!$TEXMFSYSVAR,!!$TEXMFLOCAL,!!$TEXMFDEBIAN,!!$TEXMFDIST,$TEXMFHOME}
. This is the simplest way but not the most efficient.
b) search based on the ls-R index files : in the new texmf.cnf add "$TEXMFHOME" to the list found in the default texmf.cnf file for the variable $TEXMF ; example : TEXMFDBS = {!!$TEXMFSYSVAR,!!$TEXMFLOCAL,!!$TEXMFDEBIAN,!!$TEXMFDIST,!!$TEXMFHOME}
; create/update the ls-R file with texhash $TEXMFHOME
for instance texhash /home/ad/texmf
if $TEXMFHOME is "/home/ad/texmf" ; if you used a symbolic link, check that it is in a $TEXMFHOME/tex subdirectory that contains subdirectories, otherwise create a dummy one.
- Check everything is fine :
kpsewhich example.sty
should give you the path to the file. If this succeed, your preferred tex editor/source should find your custom .sty/.cls files.
Sources : kpathsea library manual, comments in the default texmf.cnf file which is in the last directory of the list obtained with kpsewhich -var-value=TEXMFCNF
, version kpathsea 6.2.1.