Tuesday, March 13, 2018

LaTeX Series: Local TeX Tree

1. Destination texmf-local: your local TeX tree

The first step is to determine in what directory the new font will live. You can't choose just any directory, it has to be part of the TeX hierarchy. The best choice is your “local texmf” tree, which you can determine as follows:
MiKTeX
Navigate through the MiKTeX program:
Start > Programs > MiKTeX > Maintenance > Roots
(or MiKTeX Settings, in older versions). Some paths shown there have a Description such as InstallUserConfig, or UserData. A tree labeledUserConfig (but not any of the others) is an acceptable target for your new fonts, if you have no permission to create a new tree. However, it is better to use a tree without a description, as follows:You can create a new local tree by clicking on Add. The folder must not contain files at its root level or MiKTeX will reject it. Files in the folder must be in subfolders similar to the subfolders in the Install root. (MiKTeX info.)
TeX Live and MacTeX
From a system terminal (aka command prompt, shell window) enter the command kpsewhich --var-value TEXMFLOCAL to see the directory name. The default on Unix is /usr/local/texlive/texmf-local.
If you are not using one of the above TeX distributions, you'll need to consult other documentation.

2. Manual Package Installation

2.1 MikTex

If you want to install your own .sty files, then you should copy the files into the directory tex/latex/mystuff relative to a new TEXMF root directory.
Example:
  1. Create a new TEXMF root: mkdir ~/mytexmf
  2. Create a sub directory: mkdir -p ~/mytexmf/tex/latex/mystuff
  3. Copy your .cls and/or .sty files to ~/mytexmf/tex/latex/mystuff
  4. Register the TEXMF root directory ~/mytexmf
The last step can be carried out in MiKTeX Console.

2.2 TeX Live and MacTeX

The following are the steps that you should follow to install a new LaTeX package into your own home directory.
  1. Download the package file(s) from wherever they are available. Most packages are available from CTAN; enter appropriate keywords in the search fields to find the files.
  2. Packages may be distributed in different ways. Many packages on CTAN, for instance, come with a .dtx file and a .ins file. If the package you are installing comes with these files, you will have to process them with latex to create the actual files that make up the package. That is, type
    latex filename.dtx and/or latex filename.ins
    to unpackage the various .sty and other files in the package.
  3. Create a directory ~Library/texmf in your home directory, if there is not one there already.
  4. Install the various package files into subdirectories of texmf as follows:
    • All .bst and .bib files into texmf/bibtex (or subdirectories)
    • All font-related files into texmf/fonts (or subdirectories)
    • All documentation files into texmf/docs
    • All other files (.sty.cls.tex, etc.) should go into texmf/tex.
Alternatively, you could put all of the .sty etc. files into the same directory as the document you are editing. However, if you end up wanting to use them again later, you will have to copy them into the new directory as well, so in the long term it is probably better to put them into ~/texmf.

Source: [1, 2, 3, 4]