Custom TeX tree

Because ~/texmf/ sucks…    #tex #latex #tree

To install custom fonts, style, etc., you usually dump them in a particular location in you $HOME. The exact location can be discovered with the command: $ kpsewhich -var-value=TEXMFHOME

The kpsewhich program is usually a part of TeXLive. The default location is something like /home/user/texmf. But if you don’t want yet another directory littering your $HOME, you can change it like this (replace ~/.texmf with whatever location you like):

$ mv ~/texmf ~/.texmf
$ mkdir -p ~/.texmf/web2c
$ cp /usr/share/texmf-dist/web2c/texmf.cnf ~/.texmf/web2c/
# change the TEXMFHOME line to look like this: "TEXMFHOME = ~/.texmf",
$ vim .texmf/web2c/texmf.cnf
$ echo -e "TEXMFCNF=$HOME/.texmf/web2c\nexport TEXMFCNF" >> ~/.bashrc
$ source ~/.bashrc

The exact location of things depends on what that thing is concretely (fonts, styles, bib styles, etc.). For our purposes, the (now unused) projector class for presentations would go in /home/user/.texmf/tex/latex/ and the Charis SIL font (which consist of a bunch of ttf files) goes in (create the sub-folders as needed):

/home/user/.texmf/fonts/truetype/

XeLaTeX has a peculiarity regarding fonts, however: if installed per user, it expects them to be in the ~/.fonts directory. Simple solution, though, just create a symbolic link:

$ ln -s ~/.texmf/fonts ~/.fonts

More generally, the first thing to do, to discover where whatever you want to install should be installed, is using kpsewhich. It can be used to do a lot of things ($ kpsewhich --help), but the one we’re interested in here, location of styles, uses the –show-path NAME option. The list of allowed names is part of the output of the --help-formats option. So for instance, to discover where to place BiBTeX style files (*.bst), run:

$ kpsewhich --show-path bst

This will output a list of locations where BiBTeX style files are searched for. It usually starts with the current location (.), and then follows a list of comma- separated alternative locations. According to our changes above, one of those locations will be:

/home/user/.texmf/bibtex/bst//

The two slashes at the end instruct bibtex to also search sub-directories. (By the way, another thing that can show up in a given path is having !! at the start. This tells bibtex not to actually search the location, but instead rely on the ls-R database. This is the database that is updated when running $ texhash .—see below.) So if you have a file called mystyle.bst, put it in the appropriate location—I would use /home/user/.texmf/bibtex/bst/—or create a folder named mystyle and put mystyle.bst inside it. Then run $ texhash . (don’t forget the dot!) from the “appropriate location” folder you used. And you’re done: you can now put: \bibliographystyle{mystyle} in any LaTeX document, and BiBTeX will find and use it!

June 15, 2022.