texlive: Personal "texmf.cnf"

The TEXMFCNF environment variable tells TeX (or rather, the kpathsea library used by TeX in typical distributions) where to look for the texmf.cnf file. (You can type kpsewhich texmf.cnf to see the location of the texmf.cnf file that will get picked up.)

For me, by default, kpsewhich texmf.cnf shows /usr/local/texlive/2017/texmf.cnf. But if I set TEXMFCNF to something else:

% export TEXMFCNF='/tmp'
% kpsewhich texmf.cnf   
warning: kpathsea: configuration file texmf.cnf not found in these directories: /tmp.

However, if I instead export TEXMFCNF='/tmp:' then kpathsea searches in /tmp first, and then the default system directories (like /usr/local/texlive/2017/ or whatever).

The documentation for all this is in the kpathsea manual, sections Path searching > Path sources > Config files, and Path searching > Path expansion > Default expansion (for the stuff about the colon).


So the answer to your question, of how to maintain a local texmf.cnf file inside your user's home directory, is:

  1. Create a file called texmf.cnf, in some place inside your home directory, say in ~/tex_config_dir. Put whatever config changes you'd like, into this file.

  2. Somewhere in your shell config (.bashrc or .zshrc or whatever you use), set the environment variable TEXMFCNF to point to that directory, ending with a colon. For example:

    export TEXMFCNF='~/tex_config_dir:'
    
  3. In any new shell (for example, after restarting your terminal), type echo $TEXMFCNF to confirm that it's set correctly, and kpsewhich texmf.cnf to confirm that your config file is the one getting picked up. Enjoy.


TEXMFCNF is an environment variable saying where to find texmf.cnf. But there are some quirks:

  • TEXMFCNF does not point to texmf.cnf itself, but the dir containing it.

  • Its value can have a : in the end, which means keep searching if not found here.

An example TEXMFCNF setting (on unix-like system) is:

export TEXMFCNF=$HOME/.texlive:

This will search for $HOME/.texlive/texmf.cnf (then search other places if not found there).

I suggest using kpsewhich --all texmf.cnf to test if your settings are successful.

Tags:

Texmf.Cnf