{"id":68,"date":"2016-09-12T17:37:30","date_gmt":"2016-09-13T01:37:30","guid":{"rendered":"https:\/\/matsguru.com\/?p=68"},"modified":"2016-09-12T18:14:17","modified_gmt":"2016-09-13T02:14:17","slug":"latex-hack-adding-a-custom-cls-to-your-search-path","status":"publish","type":"post","link":"https:\/\/matsguru.com\/?p=68","title":{"rendered":"LaTeX hack: Adding a custom .cls to your search path"},"content":{"rendered":"<p>After a few hours of frustrated head bashing against my desk, I&#8217;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 &#8212; yet simple &#8212; two steps, I will record them here. (Yep, that&#8217;s 4 whole hours for 2 lines of code.)<\/p>\n<p>First let me give credit where credit is due. <a href=\"http:\/\/tex.stackexchange.com\/questions\/1137\/where-do-i-place-my-own-sty-or-cls-files-to-make-them-available-to-all-my-te\">This page helped me immensely.<\/a> Thank you, you wonderful LaTeX hackers.<\/p>\n<p>Let&#8217;s assume you&#8217;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\u00a0easy 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.<\/p>\n<p>For this example, I&#8217;m going to call that file <samp>syllabus.cls<\/samp>. Let&#8217;s put that into its own unusually named folder<br \/>\n<samp>~\/some\/path\/syllabus\/syllabus.cls<\/samp><\/p>\n<p>Before we move ahead to the two lines of code, you&#8217;ll need to learn a bit about your LaTeX installation. This is the head-bashing\u00a0part.<\/p>\n<p>(In case you&#8217;re curious: I&#8217;m on a Mac OSX (Yosemite) with TeX-Live 2015. Also, I use <a href=\"http:\/\/mactex-wiki.tug.org\/wiki\/index.php\/SyncTeX#TeXlipse.2FSkim\">TeX-lipse (with Skim)<\/a> for my editor.)<\/p>\n<p>Open your Terminal and type<\/p>\n<pre><samp>kpsewhich --var-value TEXMFLOCAL<\/samp><\/pre>\n<p>For me, this returns<br \/>\n<samp>\/usr\/local\/texlive\/texmf-local<\/samp><\/p>\n<p>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.<\/p>\n<p>One needs to dig a bit deeper to:<br \/>\n<samp>\/usr\/local\/texlive\/texmf-local\/tex\/latex\/local<\/samp><\/p>\n<p>I don&#8217;t know if this is true for everybody, but that was the case for me.<\/p>\n<p>And now, the moment you&#8217;ve all been waiting for:<\/p>\n<pre><samp>\r\nsudo mv ~\/some\/path\/syllabus\/ \/usr\/local\/texlive\/texmf-local\/tex\/latex\/local\r\nsudo texhash\r\n<\/samp>\r\n<\/pre>\n<p>And that&#8217;s all. Now back to writing up some\u00a0syllabi.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a few hours of frustrated head bashing against my desk, I&#8217;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 &#8212; yet simple &#8212; two steps, I will record them here. (Yep, that&#8217;s 4 whole hours for 2&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3,4],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-code","tag-latex"],"_links":{"self":[{"href":"https:\/\/matsguru.com\/index.php?rest_route=\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matsguru.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matsguru.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matsguru.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matsguru.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68"}],"version-history":[{"count":7,"href":"https:\/\/matsguru.com\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/matsguru.com\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions\/88"}],"wp:attachment":[{"href":"https:\/\/matsguru.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matsguru.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matsguru.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}