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.
Step 4
Done. Congratulation.
Old comments below this question should be removed because they might be no longer relevant to this final edit.
kpsewhich --var-value TEXMFLOCAL
and see what's the answer.;
at the end. This ensures that a possible system-wide setting ofTEXMFLOCAL
is evaluated too.texmf.cnf
you modified is actually used: Run the commandkpsewhich texmf.cnf
. It should returnC:/texlive/2010/texmf.cnf
kpsewhich texmf.cnf
say?,E:/A/My LaTeX/MyLibrary
toTEXMFLOCAL = $SELFAUTOPARENT/../texmf-local
in the global texmf.cnf is the easiest way. But don't forget to executetexhash
as well.