On this page:
On Windows, I use the MiKTeX distribution of LaTeX. I can define my local texmf directory to be anywhere I like in my user directory. I have defined my local texmf directory to be on Dropbox. This allows me to maintain one set of files only no matter whether I use my desktop, my laptop or even my portable installation of MiKTeX and Dropbox on computers I can’t install software on (e.g. those in libraries). I think my installation of LaTeX on Ubuntu can also use it, but I may be making that up.
I now own a MacBook Air with, I believe, Snow Leopard on it. I installed the MacTeX distribution of LaTeX, but I was unable to determine in two minutes how to define a local texmf directory, so I gave up. It wasn’t urgent, anyway. However, I have just had a look on the internet to see how it could be done. It’s unsatisfactory, as far as I can see.
I found that LaTeX on the Mac expects the local texmf directory to be in a specific place, namely ~/LIBRARY/texmf, where ~/LIBRARY is found in your user directory. (If you type ls at a newly opened terminal window, you should see it listed.)
I discovered this from cameron.bracken.bz [1], who pointed out that there’s a document called /Applications/TeX/What Is Installed.pdf, which you can find if you change directory up a few levels (either ls ../.. or cd ../.. then do ls to see the /Applications/TeX directory), which contains the following paragraph:
Incidentally, if you want to add files to TeX Live for one particular user, install them in a similar tree ~/Library/texmf where ~/Library is the Library folder in that user’s home directory. The folder texmf and other folders for the tree will have to be created. For instance, TeX will find any file in ~/Library/texmf/tex or a subfolder of this location, LaTeX will find any file in ~/Library/texmf/tex/latex or a subfolder of this location, and BibTeX will find any .bib file in ~/Library/texmf/bibtex/bib or a subfolder of this location, and any .bst file in ~/Library/texmf/bibtex/bst or a subfolder of this location. It is not necessary to use texhash when adding files to this local tree.
What Is Installed.pdf
That’s great. But this means I’m going to have to put another copy of my files there, so I’ll have two lots of files to maintain. This is a bad thing. And I thought Macs were supposed to be so brilliant.
I did a bit more searching, and I discovered I’m not the only one who puts/wants to put common LaTeX files on Dropbox: the second part of Zbigniew Nitecki‘s second question is pretty pertinent [2]:
2. Even more to the point, I want to put these files in DropBox so that again I have only one copy to modify when I need to. Where do I put them in Drop Box so that TeXShop will find them when I
\usepackage
them? (of course, TeXShop resides in two copies, one on my laptop and one on my iMac).
And can that be designed so that these files get used when I am using TeXShop on a file that didn’t come from Drop Box as well?Zbigniew Nitecki tug.org
There are two useful responses, both suggesting the same solution: symbolic links, although the difference between symbolic links and hard links is mysterious to me, and not the subject for this page.
I don’t know much about Drop Box, but I would suggest putting them a single folder inside your dropbox, and then creating a symbolic link inside the local texmf folder on each of the macs to that dropbox folder. Then the dropbox folder will appear as if it is in the local texmf folder.
Assuming that your files are just of one type (e.g. latex packages) you would make the link inside ~/Library/texmf/tex/latex
To make the symbolic link
ln -s <path-to-dropbox-dir> ~/Library/texmf/tex/latex/<local-dir-name>Alan Munn tug.org
This seems to be the answer. One question, though: will it be ok to link to the whole texmf directory, or is it somehow limited to a certain number of directory levels?
M. Tamer Özsu says it’s ok:
Leave them where they are in your texmf folder and put a symbolic link to it inside the Dropbox folder. To avoid having to worry about each file, I simply put a symbolic link to the entire texmf folder in my Dropbox folder.
M. Tamer Özsu tug.org
So that’s how to do it (although they seem to be doing it the other way round); now, will it work? I typed into the terminal, from my user directory, the following, making sure the full path to the Dropbox directory was included:
ln -s /Users/<Username>/Dropbox/LaTeX/localtexmf/ ~/Library/texmf
There was no output, but there is now a texmf directory in the ~/Library directory. Typing ls -al in the ~/Library directory shows a mapping from texmf to the Dropbox directory, and an ls inside texmf shows your LaTeX files.
So, will the Dropbox files be found if I run LaTeX?
I have a ‘Hello World’ LaTeX file, so I added \usepackage{avm}
to it (the AVM package isn’t included with any distribution that I know of), and ran pdflatex helloworld. It worked. Hurrah.
(Thanks to Colin for his help with the last bit.)
References
- http://ww38.cameron.bracken.bz/local-texmf-tree-on-mac-os-x
- Zbigniew H Nitecki’s original question is at https://tug.org/pipermail/macostex-archives/2011-October/047686.html