LaTeX hack: Adding a custom .cls to your search path

After a few hours of frustrated head bashing against my desk, I’ve finally figured out a way to add a directory containing a custom class file to my TeX search path. So before I forget the vital — yet simple — two steps, I will record them here. (Yep, that’s 4 whole hours for 2 lines of code.)

First let me give credit where credit is due. This page helped me immensely. Thank you, you wonderful LaTeX hackers.

Let’s assume you’ve created an amazingly useful class file that is useful to no one else but you. (This would also apply for a custom style file (.sty) as well.) And say you want to use that class for more than one LaTeX project. It would be easy to just have the .cls file in the same folder as your LaTeX project. But you want to have just the one .cls for multiple LaTeX projects.

For this example, I’m going to call that file syllabus.cls. Let’s put that into its own unusually named folder
~/some/path/syllabus/syllabus.cls

Before we move ahead to the two lines of code, you’ll need to learn a bit about your LaTeX installation. This is the head-bashing part.

(In case you’re curious: I’m on a Mac OSX (Yosemite) with TeX-Live 2015. Also, I use TeX-lipse (with Skim) for my editor.)

Open your Terminal and type

kpsewhich --var-value TEXMFLOCAL

For me, this returns
/usr/local/texlive/texmf-local

From the many posts I read on tex.stackexchange, I expected that it would be enough to place my syllabus folder right here. But it turns out life is not so kind.

One needs to dig a bit deeper to:
/usr/local/texlive/texmf-local/tex/latex/local

I don’t know if this is true for everybody, but that was the case for me.

And now, the moment you’ve all been waiting for:


sudo mv ~/some/path/syllabus/ /usr/local/texlive/texmf-local/tex/latex/local
sudo texhash

And that’s all. Now back to writing up some syllabi.