I have the same problem as in this question, but since it's too old I guess it is better to open a new question than to wait for clarification in a 7 years old answer.

I have a .sty file with stuff I want to use, and I'm trying to find the correct directory to put the .sty file, following Stefan's answer in the linked question. When I call

kpsewhich -var-value=TEXMFHOME

I get /home/terek/texmf, as predicted. There is no such directory here (even when I show hidden files). Several other similar questions and answers (such as here) mention a directory like ~/texmf/tex/latex/something/. Am I supposed to create that directory?

Searching, I have a bunch of other "texmf" directories, and I don't have a clue of what is the correct one, so see for yourself:

enter image description here

Bear in mind that I am a beginner linux user, and I'll likely ask for silly clarifications. I am also aware that the question title isn't very informative, but I am so lost that I can't think of anything better, so feel free to edit it if you want.

  • Normally you should have texmf-local directory, which is the place to store the files not in the distribution that are available to any user of your computer. Of course you have te organise these files according to the T.D.S., say texmf-local/tex/latex/foo/foo.sty, and if you have a documentation it should be in texmf-local/doc/latex/foo/foo.pdf. – Bernard Aug 20 '17 at 23:37
  • 1
    T.D.S. is an acronym for TeX Directory Structure. It's strange you don't have a local root. You can create one. It should be installed in the same directory as the main texmf. – Bernard Aug 20 '17 at 23:42
  • 2
    It should be texmf-dist. You'll have more details in the TeX Live user guide. – Bernard Aug 20 '17 at 23:49
  • 2
    If you just want to use the .sty file yourself. If it is personal to you, especially if it is being edited for you by you, put it in the home tree. mkdir -p $(kpsewhich -var TEXMFHOME)/tex/latex/<name of package>/ and put the .sty file there. – cfr Aug 21 '17 at 0:06
  • 2
    It isn't better technically. But it is the standard layout. Hence, it makes the file's location predictable. It 'fits'. It makes things easier to understand for people. TeX will find it anyway, but sometimes packages have multiple files here - several .stys or a combination of a .sty and other files. If you have packages A and B, all of package A's files are in tex/latex/A/ and all of B's in tex/latex/B/ etc. So you can see immediately which package a file belongs to and which LaTeX files a package provides. If A provides e.g. fonts, these will be in e.g. fonts/.../A/ etc. – cfr Aug 21 '17 at 2:36

For TeX Live, manually installed files should be located in one of two trees (in the standard case).

The basic idea is that there are (er ... roughly) three trees. The MAIN tree is handled by TeX Live's package manager (for an upstream install) or your Linux distro's package manager (for a repackaged install). You should not add, modify or remove files in this tree at all by hand.

The second is the LOCAL tree. This is for packages installed locally for all users. Its location is given by

kpsewhich -var TEXMFLOCAL

The third is the HOME tree. This is for personal single-user packages. Its location is given by

kpsewhich -var TEXMFHOME

However, font support packages should NEVER1 be installed into TEXMFHOME but ALWAYS1 into TEXMFLOCAL even on single-user systems. Undoing this is more complex than never doing it, because merely uninstalling and installing into the right place doesn't undo the damage.

Once you know which tree you are using, you need to figure out where in that tree to put the files. For LaTeX packages, .sty files must end up somewhere under <root of tree>/tex/latex/ but preferably under <root of tree>/tex/latex/<name of package>/ as this helps keep your tree intelligible by human beings. Likewise, documentation goes under <root of tree>/doc/latex/<name of package>/. You can usually see where things belong by looking at the structure under TEXMFMAIN and mirroring the hierarchy below the root.

Most files, including .sty files can also be included in your working directory - wherever your .tex is - and will be found without messing around with the tree structure issue at all.

1 As with most such rules, this may be broken if you really know what you're doing and why you are doing it. However, the only case in which you might reasonably consider doing this, albeit with a heavy heart, is one in which you lack authorisation to modify the LOCAL tree and have been unsuccessful in prolonged efforts to persuade the administrator of your local TeX installation to install the font packages of your dreams. Even then, the sensible course will generally be to forgo the fonts concerned. 'I prefer it' is inadequate. 'My report requires a symbol not otherwise available to me at all and my report represents a major life project or has substantial social, moral or cultural value' might be good enough, but probably it is easier to change your life goals and/or society's values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.