18

I would like to know if it's possible to change the default TEXMFHOME location. Partly because I dislike the idea of programs cluttering my home directory with non-hidden files or directories (such as ~/texmf/) and partly because I would like to be able to manually install new LaTeX packages wherever I like, for example in

/software/local-foo/
/software/local-bar/

I know I could change the TEXMFHOME environment variable, but is there also a per-user config file which could change where LaTeX & friends look for files?

3 Answers 3

17

It's not clear from the question whether you have admin access to the master texmf.cnf file. If you do, then this is easier than if you do not!

Admin access available

In the case where for example you have a single-user machine and so write access to texmf.cnf in the installation directory, this is doable with no variable setting. You can find where this is using kpsewhich texmf.cnf: I see

palladium:~ joseph$ kpsewhich texmf.cnf
/usr/local/texlive/2012/texmf.cnf

You can then edit this file (with sudo if needed) and alter the TEXMFHOME line to point to where you want.

Admin access not available

The more common case, I think, if wanting to set things here is when you do not have admin access which is exactly why you want to set on a per user basis. Here, it seems you have to set at least one variable. There are two approaches.

The first is to set TEXMFHOME directly. This is clearly pretty easy, and is the recommended method unless you need to do more complex things.

The second approach is to set your system up to use a per user texmf.cnf file. This can go in a location of your choosing, but you will need to set the TEXMFCNF variable with something like

export TEXMFCNF=~/.texmf-config/web2c:

where the : is important as it makes this an additive change. You can then create a texmf.cnf file in this new location, and add whatever settings you want there (TEXMFHOME is just one possible). There is more detail on this in http://people.debian.org/~preining/TeX/TeX-on-Debian/ch2.html#s-sec-user-config-files.

4
  • How can I point the TEXMFHOME variable to two texmf folders? I came from miktex and was able to keep the default while adding a personal folder (same structure) as root.
    – Heisenberg
    Nov 10, 2013 at 2:51
  • 1
    @Anh You can have more than one location in the variable: separate them by colons (as is done for example in tex.stackexchange.com/questions/30494/…).
    – Joseph Wright
    Nov 15, 2013 at 18:22
  • 1
    Is this still a valid solution after a couple of years? The file web2c/texmf.cnf has a warning sign to not edit the file directly, and instead referring to texmf.d to make changes. However, this file is blank and it's not clear what to change there.
    – Diego-MX
    Jan 9, 2016 at 1:35
  • 1
    @Diego You should have two texmf.cnf files: for me kpsewhich --all texmf.cnf gives /usr/local/texlive/2015/texmf.cnf and /usr/local/texlive/2015/texmf-dist/web2c/texmf.cnf. The latter is the 'do no edit' one: you ca though add lines to the former to override.
    – Joseph Wright
    Jan 9, 2016 at 7:50
1

With Unix, a symbolic link can help. For example, on my system, TEXMFHOME is set to /home/alba/texmf.

% kpsewhich -var-value=TEXMFHOME
/home/alba/texmf

To use /home/alba/Library/program/texmf instead:

% ln -s /home/alba/Library/program/texmf /home/alba

% ls -l /home/alba/texmf
lrwxrwxrwx. 1 alba alba 32 30 déc.  15:29 /home/alba/texmf -> /home/alba/Library/program/texmf

The link does not depend on shell environment, does not require admin access and can't be broken by software update.

1

Following Joseph Wright solution above, without touching any "do not edit!" file, you could:

  1. Locate your texmf directory (on Ubuntu should be /etc/texmf)

  2. Navigate to the texmf.d subdirectory

  3. Edit (possibly with sudo) the .cnf file (again, on Ubuntu should be 00debian.cnf) adding a new line:

    TEXMFHOME=/your/new/path

Please note that you can use local variables, so if you want each user to hold their texmfhome under their home, you could type:

TEXMFHOME=$HOME/.texmf
  1. Save the file and run sudo update-texmf

You can now check that the variable is update with

kpsewhich -var-value=TEXMFHOME

*edited to reflect the remarks by StrongBad (thank you)

2
  • Don't do /home/$USER/ instead do $HOME.
    – StrongBad
    Jan 18, 2019 at 18:29
  • @StrongBad thank you, edited to reflect this. Jan 20, 2019 at 10:54

You must log in to answer this question.

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