[Tex/LaTex] way to use a document class/package from another folder


I am building a document class and a set of packages to be used as templates for various documents. I'd like to aviod having to copy those over to another folder every time I use them, but I'd also like to avoid cluttering up the folder containing document classes and packages with tex files (and all the output noise…).

I tried starting a document with \documentclass{../templates/mycls}, but since mycls.cls starts with \ProvidesPackage{mycls}, I get naming problems in macros that use \@currname (for example some macros in the kvoptions package).

Is there any way I can use a document class or package from a different folder, without having to install that folder into the local TeX distribution?

Clarification: There seems to be some confusion on what I'm trying to do here. What I want to accomplish is a folder structure like the following:


The reason for this is that I want to make it very clear which files are related to templates, and which files are just documents using the template, so that when someone comes to get the templates from me, they'll know which files they need. However, with the folder structure above none of the documents in the /documents/ folder can be compiled without copying the template files into /documents/. I don't want duplicate files.

I am not interested in how to install packages under various TeX distributions (I'm working on MiKTeX, and I know how to do that here…) – I just want to make it as easy as possible for people to find the template files.

Best Answer

I think the easiest way, one that doesn't involve playing with environment variables (which can be tricky to get right when you're using graphical programs not launched from the command line) would be to put your document class in ~/texmf/tex/latex/mycls/mycls.cls.

With MiKTeX, you need to register a local additions directory. I have no experience we this, but this page looks like it has all of the information you need to do that.

Related Question