# Is it feasible to create a standalone package for fonts / styles / layouts?

For many of my recent documents, I have started using a rather specific set of packages, settings, fonts and configuration. In one rare case, I even adapted one of the included fonts (in my opinion the \partial d should not be slanted when used as a derivative sign; if it is slanted, it specifies the boundary of a set).

All of these settings are of course only made on one computer and specifically the font things had to be put into the texlive/local tree which makes sharing the settings on several computers a pain (not to think of synchronisation issues) and sharing with collaborators virtually impossible.

Ideally, I’d want to create a git repository (or any other DVCS) for all those settings and for each new tex project, I’d copy (or clone or link or use a submodule) this repository into a subdirectory of the main tex file and have it automatically included somehow, so that all my private fonts, settings and packages are found and added without problems.

Is this possible without large problems or will tex need some special initialisation routines and fixed paths for this even today?

I suspect, I’m not the only one with those problems. How is such a thing solved by others?

Edit / Explanation

I more or less think of the optimal solution to work like a style folder in a HTML file. So, I’d have a folder style with all fonts and images in it and a special style sheet, which references all those files. This solution would be totally local and portable. I could move the folder around, rename it or even use the very same folder for all my HTML files, as long as I can reference the main style sheet file. This works because all paths inside the CSS file are relative to that file.

The only adaptations I’d have to make are copying/linking/cloning the style folder and figuring out the path to the CSS file.

I don’t expect the tex solution to be identical. It is a completely different system. But it would be great to do just these two things:

• clone the style/font repository into some subfolder of the current main tex file
• inside the main tex file: include the style file
• done

Including the main file might even take a couple of lines to write, no problem there. But I’d very much appreciate it if all of these changes could be local to the folder of the main tex file.

-

The best way is to create your own package. This is simple a text file that you save with a .sty extension for example mypreamble.sty

A minimum example is shown below:

\ProvidesPackage{mypreamble}
\def\test{...}

You use the ProvidePackage command to make sure that LaTeX knows about it and give you some sensible errors if it is loaded twice.

Personally I have quite a few private packages, one is called typography where I keep all typographical tweaks and settings. Another one is specialmaths etc.

These can be installed as all other packages so you do not have any problems with paths etc.

-
Packaging the style files is a good thing of course but does not solve the sychronisation problem and the font files. –  Debilski Feb 23 '11 at 13:19

In miktex I would put all the stuff together in a special new local texmf-tree and "mount" this tree by adding its root folder as a new root. It's easy to put a such a texmf tree in a git (or whatever) repository.

In TeXLive this is also possible. While in general people think that there exist only one local texmf-tree it is actually possible to have more then one. In the TeXlive list this command was sent some month ago (untested as I have miktex):

tlmgr conf texmf TEXMFLOCAL '{/path/to/tree1;/path/to/tree2;...}'

After updates/changes of the tree you must call texhash and perhaps call updmap(-sys).

-
Joseph Wright writes in an answer to "How to add an extra searchable dir with personal style files to TeXLive, NOT under ~/Library/texmf? " that texhash is not necessary if you change TEXMFHOME. –  Matthew Leingang Feb 23 '11 at 13:00
Do you know, if I can add the current folder, e.g. the folder with my main tex file to TEXMFLOCAL/TEXMFHOME? –  Debilski Feb 23 '11 at 13:26
With Miktex you can get problems if you compile files in a active texmf: auxiliary files are often not found. I don't know if it works in TeXlive. But I wouldn't do it. A texmf-tree is for "tools" (packages, fonts, documentation), not for documents. –  Ulrike Fischer Feb 23 '11 at 14:13
Ah, okay, I see. An if I specified it as ./local/texmf? –  Debilski Feb 23 '11 at 14:59

You seem to have competing goals. If you want modularity, break off the code you reuse in your documents and distribute it separately. If you want portability, keep it within the single file.

-