6

In order to have a non-TeXlive .sty file available, I followed the recommendations of this question : Where do I place my own .sty or .cls files, to make them available to all my .tex files?.

I did as indicated, but kpsewhich didn't find my CmathLuaTex.sty file, nor TeXmaker nor TeXworks could.

So where is the bug ?

1 Answer 1

4

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 :

  1. Type kpsewhich -var-value=$TEXMFHOME to know where the texmf user trees should go (example : /home/ad/texmf)
  2. 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
  3. 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 :
  4. 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 ).
  5. 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.
  6. 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.

5
  • hm, is this answer to your question?
    – Zarko
    Mar 8, 2018 at 16:35
  • May be a lengthy one ... But definitely yes : last week, due to a failure in the upgrade of Ubuntu from 16.04LTS to 17.10, I had to reinstall all my TeX environment and thanks to this, I was able to do it "quickly" when at first I spent many many hours. Mar 13, 2018 at 9:51
  • ok. then you can accept it (since your problem is solved by it) :-)
    – Zarko
    Mar 13, 2018 at 9:53
  • I didn't think I could do it myself . Done ! Mar 13, 2018 at 9:55
  • Shouldn't kpsewhich -var-value=$TEXMFHOME be instead kpsewhich -var-value=TEXMFHOME (without the $). The former gives an "empty argument for var-value` on my macOS system, whereas the latter correctly gives the path.
    – murray
    May 10 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .