30

I create my own documentclasses and packages in some directory of tex\latex. The directory tex\latex itself might be in any other directory in any drive. I can register the packages/classes to Miktex as already posted in my answer here. Putting the documentclass or packages in a dedicated directory in a separate drive is practically useful to avoid data loss when the system crashes.

But how to do this for TeX Live?


Based on Ulrike's answer I do the following steps and it works.

Step 1

Open C:\texlive\2010\texmf\web2c\texmf.cnf to see how TEXMFLOCAL is defined.

% .... other settings before this line have been removed for simplicity. 
%
% A place for local additions to a "standard" texmf tree.
% This tree is not used for local configuration maintained by
% texconfig, it uses TEXMFCONFIG below.
TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local
%
% .... other settings after this line have been removed for simplicity. 

Step 2

Open C:\texlive\2010\texmf.cnf and modify it as follows.

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
OSFONTDIR = $SystemRoot/fonts//
%============== Below this row is my modification ====================
%
% My custom packages and classes are
% in E:/A/My LaTeX/MyLibrary/tex/latex/misc.
%
TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local,E:/A/My LaTeX/MyLibrary
%
%
% It is wrong if you do like below
% TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local,E:/A/My LaTeX/MyLibrary/tex/latex/misc
% or
%TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local,E:/A/My LaTeX/MyLibrary% comments

Packages and classes must be in some subdirectory of tex\latex. In my example above, they are in E:/A/My LaTeX/MyLibrary/tex/latex/misc directory. I am not sure spaces in the path still work in OS other than Windows.

Step 3

Invoke texhash as follows.

enter image description here

Step 4

Done. Congratulation.

Old comments below this question should be removed because they might be no longer relevant to this final edit.

18
  • 1
    @xport I wouldn't use spaces in the path, they are a sure source of problems. Try asking kpsewhich --var-value TEXMFLOCAL and see what's the answer.
    – egreg
    Jun 7, 2011 at 11:05
  • @xport: spaces in paths are extremely dangerous and may be the reason for failure. Append ; at the end. This ensures that a possible system-wide setting of TEXMFLOCAL is evaluated too.
    – AlexG
    Jun 7, 2011 at 11:07
  • @xport. Your settings seem to be ignored. Please verify, whether the texmf.cnf you modified is actually used: Run the command kpsewhich texmf.cnf. It should return C:/texlive/2010/texmf.cnf
    – AlexG
    Jun 7, 2011 at 11:44
  • @xport: What does kpsewhich texmf.cnf say?
    – AlexG
    Jun 7, 2011 at 11:49
  • 2
    I think appending ,E:/A/My LaTeX/MyLibrary to TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local in the global texmf.cnf is the easiest way. But don't forget to execute texhash as well. Jul 5, 2011 at 18:26

5 Answers 5

15

OK. At request I sum up my comments as an answer:

I don't have a full TeX Live but I have a skeleton (for LuaTeX). I have added various texmf trees (e.g. from MiKTeX) from various drives to texmf.cnf and it works fine. The syntax I used is

 TEXMFLOCAL = I:/TeX-Roots/microtype,I:/TeX-Roots/UFlocaltexmf,...

(commas between the roots, no slashes at the end, no comma at the end, the ... stand for more pathes).

The variable TEXMFLOCAL is then used later on in my (complete) texmf.cnf like this:

TEXMF = {!!$TEXMFMAIN,!!$TEXMFLOCAL, ...}

Normally TEXMF should already have this definition in the global texmf.cnf so it shouldn't be necessary to reset it in the local texmf.cnf. kpathsea reads all texmf.cnf. Settings in earlier (local) ones wins.

You should check if you didn't loose the texmf trees from the original TEXMFLOCAL definition (perhaps it did contains something before).

Check the list of pathes/texmf.cnf with kpsewhich -show-path=cnf or (according mpg) kpsewhich -a texmf.cnf.

If you have a MiKTeX installation, check that you are not using its texhash (try texhash --version).

0
11

With a default TeXLive installation you have a directory c:\texlive\texmf-local. There you can save your own files. This local directory has the same subdirectories as the default main one. LaTeX files should be saved in texmf-local\tex\latex\.... After saving your files run as command texhash to update the data base.

you can run from the command line kpsewhich -expand-var '$TEXMFHOME', then you see the default home directory. You can change this variable for your needs. You have three trees: $TEXMF, $TEXMFLOCAL, and $TEXMFHOME.

0
8

You can easily add package directories which reside outside the c:/texlive directory. Just append them, separated by ;, to the TEXMFLOCAL variable in the configuration file c:/texlive/texmf.cnf of your installation and run the texhash command. This will add all files found to the file name data base.

EDIT: Here is my texmf.cnf:

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
TEXMFLOCAL = $SELFAUTOPARENT/texmf-local;/home/grahn/texpkgs
TEXMFHOME = $TEXMFLOCAL
TEXMFVAR = $TEXMFSYSVAR
TEXMFCONFIG = $TEXMFSYSCONFIG
ASYMPTOTE_HOME = $TEXMFCONFIG/asymptote
TEXINPUTS=.//;
main_memory = 30000000

As far as I know, this file was installed during TeXLive installation (I was using the --portable option). The additions I did are the TEXINPUTS and main_memory lines and the additional directory in TEXMFLOCAL for illustration. Always use / in paths (even for Windows). TEXINPUTS=.//; lets TeX search for files in subdirectories of the current one.

4
  • @xport: the usual value for TEXMFLOCAL is given by TEXMFLOCAL = $TEXMFROOT/../texmf-local Copy this line into the texmf.cnf file and append ;x:/path/to/right/place. Note that this requires your external disk is always mounted with the same specifier (here x). Maybe Windows has some way to refer to devices by name.
    – egreg
    Jun 7, 2011 at 10:13
  • @xport: I think so, but I don't know Windows. I would use the exact capitalization, though, just in case.
    – egreg
    Jun 7, 2011 at 10:27
  • @xport: always use / in paths.
    – AlexG
    Jun 7, 2011 at 10:32
  • 2
    @xport: you have many texmf.cnf files. Try kpsewhich -a texmf.cnf to list them. The first (and shorter) one is the one you found, meant for local editions. The other one is much longer, contains all the settings and should not be edited manually but can serve as example/documentation.
    – mpg
    Jun 8, 2011 at 5:58
3

As already mentioned by @mpg, there are 2 texmf.cnf files. The one with a shorter path is for user-defined settings. The other one with a longer path is for factory-default settings and should not be edited by users.

However, in my experience, the user-defined texmf.cnf seems to be ignored or its settings do not affect anything even though you invoke texhash after editing it. That is why I always edit the factory-default texmf.cnf file.

Open the factory-default texmf.cnf, locate TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local, and append ;E:/A/My LaTeX/MyLibrary. So it becomes

TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local;E:/A/My LaTeX/MyLibrary

Finally invoke texhash.

Note that you have to change \ to / and use ; as appending delimiter. When you update your TeXLive installation then redo this ritual because factory-default texmf.cnf will be reset to its default settings.

2

With TeX Live 2017 it is very easy to register a new TEXMF tree. Assume your files are in E:/A/MyLaTeX/MyLibrary/tex/latex/misc. So the new TEXMF tree would be E:/A/MyLaTeX/MyLibrary. Now, open a console window and type in:

tlmgr conf auxtrees add "E:/A/MyLaTeX/MyLibrary"

Linux or OS/X users may need to use sudo:

sudo tlmgr conf auxtrees add "E:/A/MyLaTeX/MyLibrary"

You can test for all these auxiliary trees and their search order using

tlmgr conf auxtrees show

And if you want to remove such an auxiliary tree just use

tlmgr conf auxtrees remove "E:/A/MyLaTeX/MyLibrary"

(here it may also be necessary to use sudo as shown above).

You must log in to answer this question.

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