0

I am trying to figure out if I can switch from Mac back to Linux after a gap of 10+ years. I installed an Ubuntu derivative on the machine, and installed TeXLive 2019 (vanilla) using the equivs business to create a dummy package called texlive-local, so that I can trick the OS into thinking that TeX is installed. This is necessary because Ubuntu LTS tex packages are outdated.

My paths are fine. I can execute pdflatex, etc. perfectly fine, and documents containing standard latex classes (or rather anything under /usr/local/texlive/2019 ...) work fine.

The problem starts when I try to compile anything that needs my custom authored classes (I have several), which I installed under /home/user/texmf (see details below).

Actually, after I initially had problems, I copied (cp -R as user, not root, not sudo) the entire texmf-local tree from /usr/local/texlive to /home/user/texlive, and placed symbolic links to folders containing my custom class files under /home/user/texmf/tex/latex/local/. While copying the empty tree from /usr/local/texlive is not required, doing so ensures that I have the right TDS tree under ~/texmf. It is good practice to do so. So, I have the following symlinks (ln -s):

customclass ---> ../../../../../Somepath/customclass
classone ---> ../../../../../Somepath/classone
classtwo ---> ../../../../../Somepath/classtwo

under /home/user/texmf/tex/latex/local where the .cls and .sty files are located under the symlinked folders above. I am writing this explicitly here so that no one has any misunderstanding about the nature of my texmf tree - the symlinks are to folders containing the class files, and not to the class files themselves.

$kpsewhich -var-value=TEXMFHOME
/home/user/texmf

I have tried setting TEXMFHOME explicitly at the end of my .bashrc, and also tried to manually export the variable, and added it to /usr/local/texlive/2019/texmf.cnf.

I have been a LaTeX user for about 22 years, and I do NOT recall using LaTeX being this hard under Linux.

On Mac, this was simple - just placing symlinks under ~/Library/texmf took care of everything. IIRC that was also the case (~/texmf) in the old days when I used LaTeX on Linux. Apparently, not anymore.

I have searched for several answers on stackexchange, and elsewhere, tried out what I found there, but it does not work. Any file using custom classes, still fails, with kpsewhich failing to find the .cls files. I have run kpsewhich on command line - my custom classes yield blank input, while article.cls produces the path to article.cls.

Edit: Yes, I have run texhash ~/texmf, and sudo texhash multiple times.

What am I missing? Before someone suggests the obvious - explicitly copy the files over to texmf, I do not want to do that. My folders containing class files are sync'ed across several machines using a combination of rsync, and cron jobs, and I don't want to maintain two copies of the same file. A symbolic link is the right tool for the job.

Edit: I backup the folders containing my class files, not ~/Library/texmf (on Mac) and not ~/texmf (on Linux). I just symlink to the backed up folder on each OS. There are multiple machines that use these class files (I run a lab, and my grad students need to be all on the same page).

Is kpsewhich on the Linux version of TeXLive broken in the sense that it cannot handle symlinks?

Given that the various answers I have found on stack exchange have slightly different situations from mine (the equivs + TeXLive install mainly), this question is not a duplicate.

Edit: I figured it out, see my answer below. The problem is that kpsewhich is lazy, and does not want to look at symlinks unless a real directory is also located at that level.

  • 1
    Where in ~/texmf did you place the symlinks? Did you set up the proper TDS tree structure? – Herb Schulz Oct 16 '19 at 20:34
  • @cfr What do sensible backup habits, avoiding chaos, and redundant copies of the same files that may lead to inconsistency, have to do with the choice of the underlying OS? – user2751530 Oct 17 '19 at 2:15
  • @HerbSchulz I did mention that a) I copied the texmf-local directory tree over from /usr/local/texlive, and b) the symlinks are under tex/latex/local. If I am actually missing any details, let me know. – user2751530 Oct 17 '19 at 2:18
  • texhash is irrelevant for ~/texmf. The directory is searched completely and not by database (unless you changed the default config). – cfr Oct 17 '19 at 2:23
  • @cfr You seem to be assuming things that are explicitly ruled out in the text of my question. Where have I mentioned that I want to use ~/Library/texmf as the tree under Linux? And, again, yes, I use symlinks because it is utterly senseless to have multiple copies of the same file scattered everywhere. And no, I don't backup ~/texmf or ~/Library/texmf. I only backup my own class files. Are you trying to imply that kpsewhich on Linux is incapable of handling symlinks? – user2751530 Oct 17 '19 at 2:29
0

@cfr You will not believe what just happened.

I liked your idea of creating a dummy class file under a dummy class folder under texmf.

So, I went ahead and did the following:

$ mkdir -p ~/texmf/tex/latex/local/class
$ cd ~/texmf/tex/latex/local/class
$ touch class.cls

Then I looked at kpsewhich output:

$ kpsewhich class.cls
/home/user/texmf/tex/latex/local/class/class.cls

So far so good. Then, I do not know why, I just had a hunch, call it a vague memory of how binary trees are searched, I tried, without doing anything else:

$kpsewhich letterwithfancieruniversityheader.cls
/home/user/texmf/tex/latex/local/letters/letterwithfancieruniversityheader.cls

!!!

Then for completeness,

$ rm ~/texmf/tex/latex/local/class/class.cls

And kpsewhich still finds my letter class file.

Apparently, texmf requires the presence of at least one real directory at the same level as symlinks. If it does not find it - my hunch is that kpsewhich is lazy and just looks at the size of the directory to decide if the next level traversal is empty, it quits looking.

This sounds like a bug in kpsewhich, or maybe it is an annoying feature. Either way, its a kpsewhich quirk to be aware of if you are sensibly using symlinks to point to templates you need, in a networked environment.

  • Report it? That seems very weird. I tested the sym links to double-check, but I never destroyed my working copy of ~/texmf. Note that local is not standard. Standard would be ~/texmf/tex/latex/class/class.cls. – cfr Oct 17 '19 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.