Adding ~/.texmf to TeX Live 2011's directories, or installing beamer themes
While trying to install the UA beamer
theme in the most appropriate way, I stumbled for the umpteenth time on this issue. Where and how to install a beamer
theme, or by extension any non-TeX Live package, without resorting to sudo mv
'ing it into /usr/local/texlive20xx/...
? I don't remember going through this process the last time I installed some packages myself, but as I recently installed TeX Live 2011 and decided to do things the proper way (at least in my opinion) I decided to write this post.
What is "installing a package" by the way? It boils down to letting programs like pdflatex
know where certain files are situated. Installing is therefore nothing but dumping the necessary files somewhere and let TeX know where it can find them. But TeX doesn't look everywhere, so we have to choose a place to dump the files and tell TeX they're there.
As Manuel Pégourié-Gonnard pointed out in the comments, this extensive approach isn't quite necessary. If you want to add your own files to In case you want the "hidden folder approach" I wrote about, performing Steps 1, 2, the first line of Step 4 and Step 7 should be fine.~/texmf
, just perform Step 7 (after creating the folder as in Step 1, of course). This should do the trick, without further ado.
A quick yet extensively documented howto:
- Open a shell and create your (hidden) local
texmf
folder by invokingmkdir ~/.texmf
. - Locate
texmf.cnf
by invokingkpsewhich texmf.cnf
. You should end up with a path like/usr/local/texlive/2011/texmf.cnf
. - Open this file as root in your favorite text editor (in case you don't yet have a favorite text editor, I suggest vim), i.e.
sudoedit /usr/local/texlive/2011/texmf.cnf
is a shortcut for this, although no-one says you cannot usesudo gedit
e.g..sudo vim /usr/local/texlive/2011/texmf.cnf
but you'll probably want to replacevim
bygedit
- Add the following two lines anywhere you like in this file (it's probably rather empty, containing nothing but comments)
TEXMFHOME = ~/.texmf
TEXMFDBS = {!!$TEXMFSYSCONFIG,!!$TEXMFSYSVAR,!!$TEXMFMAIN,!!$TEXMFLOCAL,!!$TEXMFHOME,!!$TEXMFDIST}In case you're interested in what's so special about this
$TEXMFDBS
variable: unlike the standard configuration, we have added our non-standard hidden localtexmf
folder by adding$TEXMFHOME
, a variable that's not there by default but that is not necessary so skip this step. Runupdmap
, this will update your configuration files. You'll get a lot of output, hopefully no errors.Runtexhash
. Its output will look like thistexhash: Updating /home/.../.texmf/ls-R... texhash: /usr/local/texlive/2011/texmf: directory not writable. Skipping... texhash: /usr/local/texlive/2011/texmf-config: directory not writable. Skipping... texhash: /usr/local/texlive/2011/texmf-dist: directory not writable. Skipping... texhash: /usr/local/texlive/2011/../texmf-local: directory not writable. Skipping... texhash: /usr/local/texlive/2011/texmf-var: directory not writable. Skipping... texhash: Done.
As we didn't run
texhash
with root privileges, most directories are skipped. Yet the first directory where the dots are replaced by your username looks promising.- Mimic the structure of
/usr/local/texlive/2011/texmf/
, i.e. in my case that means I have to add thebeamer
theme in the folder~/.texmf/tex/latex/beamer/themes/theme/
(or possibly some variation on this, but I decided to do it the strict way).
The benefits of this approach are immediately obvious: we can write in our ~/.texmf
folder as we like and run texhash
without root privileges. And it's hidden from our view if we don't bother about hidden files! So we've fixed twoone issues:
- TeX Live 2011 defines
$TEXMFHOME
as~/texmf
but we want it to be invisible so we've overridden the value with~/.texmf
. TeX Live 2011 ignores$TEXMFHOME
for its filename database. Hence your files would never have been found.
What remains is an explanation on how to configure TeX Live 2011 to look in a hidden folder, instead of its default visible folder. The rest can safely be ignored.