I have several *.cls files that serve as a template for our company documents. It will create titlepages, copyright notices, add company logos to standard-formatted headers/footers, etc. How can I package my cls files and image resources so authors have more flexibility in their *.tex file locations.

Currently everything is deployed in a version-control-system in a flat filestructure. i.e. Our 25 classes, and thousands of tex documents are in one directory. This is because we need the *.cls files to be in the same directory as the *.tex files to be able to pdflatex them.

It's getting unmaintainable.

Instead, I'd like to deploy my *.cls files in a Debian package system-wide, so authors can create their own projects with their own *.tex files in a location of their choosing. Then, they \documentclass{servicebulletin} or \documentclass{testmanual} in the same way they would do this with the default article, report, or book classes.

Is this as simple as making a Debian package which deploys my classes to /usr/share/texlive/texmf-dist/tex/latex/base/?

  • 1
    you certainly shouldn't put something into latex/base, that is for latex itself. Use a folder like tex/latex/mycompany. And normally local packages should better go into texmf-local and not into texmf-dist, or add them as their own tree with tlmgr conf auxtrees (if your user can use tlmgr). Jan 28, 2022 at 10:10
  • This is exactly the info I'm looking for. What are the search paths? Would my users need to do anything to make latex search in texmf-dist/tex/latex/mycompany or texmf-local/tex/latex/mycompany?
    – Stewart
    Jan 28, 2022 at 12:52
  • 1
    texmf-dist need a call of mktexlsr, texmf-local perhaps too, not sure, I typically use dedicated texmf-trees. Jan 28, 2022 at 13:02
  • Great. I'm getting close. I put a class in /usr/share/texlive/texmf-dist/tex/latex/mycompany/ and ran sudo mktexlsr and generated the document! But I'm having trouble with texmf-local. I've created tex/latex/mycompany/*.cls and put it in /usr/share/texlive/texmf-local, /usr/share/texmf-local, /usr/local/texlive/texmf-local, then run sudo mktexlsr <dir> on each directory to no avail. How can I find the location of TEXMFLOCAL or define my own texmf-* location?
    – Stewart
    Jan 28, 2022 at 13:37
  • 1
    On windows I can do kpsewhich --expand-var $texmflocal and get back the path. See kpsewhich --help. And if I want to add a new tree I use tlmgr conf auxtrees add ... see the docu of tlmgr. Jan 28, 2022 at 14:03

1 Answer 1


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:


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:
$ 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

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

$ kpsewhich -show-path texmf.cnf
  • Small bug if you are adding texmf trees from different packages: Only the first definition of TEXMFAUXTREES = is used by update-texmf. That's not a problem for my use case, but someone may care to edit in the future to make this more friendly.
    – Stewart
    Jan 31, 2022 at 14:02

You must log in to answer this question.

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