Create your texmf tree
*.cls files and other resources should be in a texmf tree. This is a tree with tex/latex/*.cls or tex/latex/<anysubdir>/*.cls
That tree can be in a few places. Below is where they are on debian-based distributions. Use kpsewhich -var-value <variable> to find out where they are on your installation.
TEXMFHOME ($HOME/texmf) is for a user-specific tree. That's not appropriate when deploying a package that is system-wide.
TEXMFLOCAL (/usr/local/share/texmf) is for a system-wide local tree. These are typically installed by the user using something other than a package manager (such as make install or git clone). This is also not appropriate if you're using a package manager.
TEXMFDIST (/usr/share/texlive/texmf-dist) is the texlive distribution. While you could deploy files in here, it would be best if you kept your stuff away from the official distribution to avoid polluting it.
TEXMFAUXTREES ({}). This is a list of additional trees that latex will use to find files. This is perfect!
Deploy your class to some path. Here is an appropriate path for a package:
/usr/share/texlive/texmf-mycompany/tex/latex/companytemplate.cls
Now we need to tell latex where to look for it.
Non-Debian instructions
You can use tlmgr to add the auxtree (you may need sudo):
tlmgr conf auxtrees add /usr/share/texlive/texmf-mycompany
Confirm it was added with:
$ tlmgr conf auxtrees
List of auxiliary texmf trees:
/usr/share/texlive/texmf-mycompany
$ cat /usr/share/texlive/texmf.cnf
TEXMFAUXTREES = /usr/share/texlive/texmf-mycompany,
Debian-specific instructions
tlmgr can conflict with apt or apt-get. Therefore tlmgr is limited to user-only mode and global effects are not respected. Instead, we need to deploy /etc/texmf/texmf.d/01mycompany.cnf. The filename doesn't matter: as long as it is in that directory and ends in .cnf. It should contain this content:
TEXMFAUXTREES = /usr/local/texlive/texmf-local,
Then in postinst, run update-texmf. This will concatenate all files in /etc/texmf/texmf.d/ and generate /etc/texmf/web2c/texmf.cnf which IS used by texlive.
Confirm everything works:
$ kpsewhich -var-value TEXMFAUXTREES
/usr/share/texlive/texmf-mycompany, <-- You need to see your path here
that means it will be searched
$ kpsewhich myclass.cls
/usr/share/texlive/texmf-mycompany/tex/latex/myclass.cls
If these don't work for you, then you can troubleshoot by looking at the *.cnf files which are loaded and where they can be found:
$ kpsewhich -all texmf.cnf
/etc/texmf/web2c/texmf.cnf
/usr/share/texmf/web2c/texmf.cnf
/usr/share/texlive/texmf-dist/web2c/texmf.cnf
$ kpsewhich -show-path texmf.cnf
/etc/texmf/web2c:/usr/local/share/texmf/web2c:/usr/share/texmf/web2c:/usr/share/texlive/texmf-dist/web2c://share/texmf/web2c
tlmgr conf auxtrees(if your user can use tlmgr). – Ulrike Fischer Jan 28 '22 at 10:10texmf-dist/tex/latex/mycompanyortexmf-local/tex/latex/mycompany? – Stewart Jan 28 '22 at 12:52mktexlsr, texmf-local perhaps too, not sure, I typically use dedicated texmf-trees. – Ulrike Fischer Jan 28 '22 at 13:02/usr/share/texlive/texmf-dist/tex/latex/mycompany/and ransudo mktexlsrand generated the document! But I'm having trouble withtexmf-local. I've createdtex/latex/mycompany/*.clsand put it in/usr/share/texlive/texmf-local,/usr/share/texmf-local,/usr/local/texlive/texmf-local, then runsudo mktexlsr <dir>on each directory to no avail. How can I find the location ofTEXMFLOCALor define my owntexmf-*location? – Stewart Jan 28 '22 at 13:37kpsewhich --expand-var $texmflocaland get back the path. Seekpsewhich --help. And if I want to add a new tree I usetlmgr conf auxtrees add ...see the docu of tlmgr. – Ulrike Fischer Jan 28 '22 at 14:03tlmgron Debian only runs in "user mode" to avoid conflicts with the debian package manager (apt,apt-get). But it appears to be able to write to/usr/share/texlive/texmf.cnfwhen run withsudo. I think I have enough to get things working. Will post an answer when complete. Thanks for your help. – Stewart Jan 28 '22 at 16:54