TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to specify a texmf directory from within a tex file? I think a project-specific way to set the TEXMFHOME environment variable, instead of within the ~/.bashrc file would work.

I mostly use the Kile LaTeX editor on KDE, but I synchronise my TeX project tree over to other computers using git; on OSX I have MacTex installed.

I've just installed the Myriad Pro OTF font package using Michael Gährken's package, and would like this font to be used on all machines without having to edit local files and folders on each host.

share|improve this question
up vote 8 down vote accepted

You can't change the kpathsea (pseudo)environment variables once the pdftex process has been started. But you can change their value before launching the process:

TEXMFHOME="/path/to/new/texmfhome:$(kpsewhich -var-value TEXMFHOME)" pdflatex filename

This will prepend the "new home" to the current value; the syntax used assumes bash.

share|improve this answer
Thanks for the explanation (+1)! I figure the LaTeX builder (e.g. Kile/MacTex) should allow configuration of the build environment. Kile, at least though, doesn't seem to have settings to configure the build commands' environment; only the commands' arguments. So to make this work (on KDE), I'd have to set TEXMFHOME in /etc/environment (or whichever file it is that configures the global KDE environment). Would you consider this a bug/limitation of Kile? Can I define TEXMFHOME in a project-specific config file or something? – Alex Leach Nov 5 '12 at 12:26
@AlexLeach Sorry, I don't know whether Kile is able to cope with this; but I'm pretty sure you can send an arbitrary shell command for typesetting also with it. – egreg Nov 5 '12 at 12:38
Good point. The template I'm using came with a Makefile, which I haven't been using, but I can configure Kile (and MacTex I imagine) to just run make. Obviously I've got to add your changes to the Makefile, but that will do :) – Alex Leach Nov 5 '12 at 13:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.