[Tex/LaTex] Finding and configuring the texmf tree

texmf

I'm trying to install a new style file that doesn't come by default with LaTeX. I'm on a Linux Mint computer, and installed LaTeX with a simple

sudo apt install texlive

or something like that, if I recall correctly. Now as I search for my texmf directory, I've found two (which I found by following some instructions at various pages on the internet). One is at /var/lib/texmf and the other is at /usr/local/share/texmf/. The former has the folders:

dvipdfmx/
dvips/
fonts/
luatex-cache/
tex/
web2c/
xdvi/
...

as well as seven files, one of them for instance is fmtutil.cnf-DEBIAN.

With some blind exploration, I don't find any .sty files in any of the sub-folders. In the other directory, /usr/local/share/texmf/ the directory is entirely empty.

So unless I just haven't explored the sub-folders of the first directory enough, I don't think either of these are where LaTeX is looking for its .sty files. So how do I find the correct directory? When I type which tex it gives me usr/bin/tex but in that directory, I don't see any other file that seems related to LaTeX.

When I run texhash it returns

texhash: /usr/local/share/texmf: directory not writable. Skipping...
texhash: /var/lib/texmf: directory not writable. Skipping...
texhash: /var/lib/texmf: directory not writable. Skipping...
texhash: /var/lib/texmf: directory not writable. Skipping...
texhash: Done.

Since I don't really know what I'm doing I didn't want to run texhash as root, but this sort of makes me think that the texmf tree has to be in one of these directories … so I'm just confused at this point.

[Edit: I've seen some people suggest that there might be a texmf tree at the home directory, but there isn't one for me. That is to say there is no texmf directory located in my ~/ directory.]

[Further edit: Also when I type echo $TEXMFHOME it returns a blank line.]

[Further edit: Per egreg's comment I entered kpsewhich -var-value TEXMFHOME which returns /home/myname/texmf but this directory doesn't exist.]

Best Answer

Local additions should not be put into the system texmf directory, i.e., /usr/local/share/texmf, but instead should be put into your home texmf folder. This folder is not created automatically, so you need to create it yourself.

The location of your local texmf can be found by using the command:

kpsewhich -var-value TEXMFHOME

On a Linux system, this will typically be ~/texmf (/home/<username>/texmf). You can create the folder yourself but it must conform to the TeX Directory Structure. See:

Once you've done this you don't need to do anything else for packages to be found; TeX looks in this directory first.