How can I keep a clean document folder with custom .cls, .sty, .bst files in a separate subfolder?
I use latexmk
for some document building, and I've wanted something like this for a long time. Especially when I have document and class under version control.
I discovered that you can configure latexmk
with a local latexmkrc
file in the document's directory. latexmkrc
files are just perl code.
So in this workflow, if the class files are in ./texmf
you can add the following line to a local latexmkrc
:
$ENV{'TEXINPUTS'}='./texmf//:' . $ENV{'TEXINPUTS'};
This works on my Mac, and I assume on any unix machine that uses environment variables this way. For windows, and indeed for any platform, latexmk
's author John Collins has a solution at his answer to a similar question.
You can in fact that environment variables inside a Makefile (tested with GNU make only). You need to do the following:
export VAR=value without quotes
If you reference the previous value of the same variable you need to use the :=
assignment instead which expands the value immediately. The normal =
is expanding the value at every use and will lead to an recursive assignment, which make
detects and reports as an error.
There are no quotes required around the value and using them might cause trouble.
Also variables must be written as ${VAR}
on the right-hand side, not $VAR
.
So you can add the following line to your Makefile, at best at the beginning:
export TEXINPUTS:=.:./texmf:~/texmf:${TEXINPUTS}