I was wondering what is the official way to add personal configurations to texmf.cnf.

I specifically want to add my own settings for this reason: Avoid linebreaks in LaTeX console / log output

But the answer there tells you to modify /usr/local/texlive/2017/texmf.cnf, which is not right. Each time you install a new version of texlive, each time you reinstall texlive, each time you acquire a new machine, each time you wipe out your system disk, you would have to modify texmf.cnf.

All personal configurations should reside under the user's home directory.

I've heard of the environmental variable TEXMFCNF and searched the net for how to use it, but I haven't found what exactly it does and how to use it to solve the particular problem I have.

3 Answers 3


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.

  • One thing that's not clear to me is how to merge your settings with the ones which are already in /usr/local/texlive/2017/texmf.cnf. Perhaps you have to copy what's in the original texmf.cnf and add your stuff to it?
    – Ryo
    Commented Jan 17, 2018 at 10:42
  • 1
    @Ryo No you just have to add the changes you want. See the documentation section linked above: “Kpathsea reads all texmf.cnf files in the search path, not just the first one found; definitions in earlier files override those in later files.” Commented Jan 17, 2018 at 13:13
  • Thanks! (I should've read the documentation before posting the comment.) So, texmf.cnf is special in this sense. I think LaTeX normally reads the version of the file it first finds and stops the search there.
    – Ryo
    Commented Jan 18, 2018 at 3:58

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.


There are a lot locations where kpathsea will look for texmf.cnf and it will use all it can find: values in earlier texmf.cnf overrides the values from later texmf.cnf.

The main texmf.cnf is in texlive/2017/texmf-dist/web2c. This should never be changed.

The one in texlive/2017 can be used for personal changes (open it to see the comments). But if you don't trust the location you can use the web2c folder of other texmf trees, e.g. texmf-local. A list of all possible location can be shown with kpsewhich -show-path=cnf.

You can also set the variable TEXMFCNF to a specific folder with the texmf.cnf but normally I don't think that it is needed.

  • Thanks that is informative. But if I don't set TEXMFCNF, then all the paths shown by kpsewhich -show-path=cnf start with /usr, i.e. none is in the user's home directory which is the main thing the OP asks for. So I think your answer is missing the main part of the question (maybe setting texmfhome)? Commented Jan 16, 2018 at 15:20
  • 1
    From the Kpathsea manual, section 5 Path searching > 5.2 Path sources > 5.2.1 Config files: “definitions in earlier files override those in later files”.
    – GuM
    Commented Jan 16, 2018 at 18:49
  • @ShreevatsaR: On the other hand, if the problem is simply to avoid that a custom setting is overwritten by later updates, then one of the locations in the compile-time defaults of TEXMFCNF, namely, /usr/local/texlive/texmf-local/web2c, can be of interest. Of course, a texmf.cnf file placed there would affect all users of a given machine, and placing it there would require appropriate access priviledges.
    – GuM
    Commented Jan 16, 2018 at 18:55
  • @GuM Yes that's exactly the problem; the expectation is that the user's config can be set in the user's directory. E.g. for my Emacs or Vim config I edit ~/.emacs or ~/.vimrc, not /usr/.... So: (1) the user does not need admin privileges, (2) the user's setting won't affect other users, (3) the user's preferences persist across system or distribution reinstalls (4) the user can sync their config files to other computers, etc. I think this answer says there exists a way of achieving this (having config inside ~ as asked) without setting TEXMFCNF, but it's not clear what that way is. Commented Jan 16, 2018 at 19:56
  • 1
    @ShreevatsaR: As far as I can understand, there’s no way of having (active)texmf.cnf files inside ~ except by setting TEXMFCNF in the environment: indeed, it is impossible to set the search path for texmf.cnf files within a texmf.cnf file, so the next source that is looked up after the environment is the compile-time path (see section 5.2 Path sources; and the compile-time path gets at most to $SELFAUTOGRANDPARENT/texmf-local/web2c, that expands to /usr/local/texlive/texmf-local/web2c, in the machine-wide custom tree.
    – GuM
    Commented Jan 16, 2018 at 23:12

You must log in to answer this question.

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