{"id":398,"date":"2011-01-15T19:15:26","date_gmt":"2011-01-15T19:15:26","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=398"},"modified":"2014-07-23T12:46:58","modified_gmt":"2014-07-23T12:46:58","slug":"a-minimal-luatex-setup-on-windows-part-3","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=398","title":{"rendered":"A minimal LuaTeX setup on Windows (Part 3)"},"content":{"rendered":"<p>In Parts <a href=\"https:\/\/www.readytext.co.uk\/?p=283\">1<\/a>, <a href=\"https:\/\/www.readytext.co.uk\/?p=333\">2<\/a> and <a href=\"https:\/\/www.readytext.co.uk\/?p=357\">2a<\/a> I made reference to such things as &#8220;environment variables&#8221; and a file called <code>texmf.cnf<\/code>. I this section of the tutorial I will try to bring these concepts together and get down to some practical details. But first we need to set the scene with a very important topic: <a href=\"http:\/\/tug.org\/texinfohtml\/kpathsea.html\">Kpathsea<\/a>.<\/p>\n<h3>Kpathsea, what&#8217;s that?<\/h3>\n<p>The name Kpathsea originates from <strong>K<\/strong>arl&#8217;s <strong>path<\/strong> <strong>sea<\/strong>rching, named after the author of the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Library_%28computing%29\">library<\/a>, <a href=\"http:\/\/www.tug.org\/interviews\/berry.html\">Karl Berry<\/a>. As discussed on the Kpathsea web pages, it was written to provide a number of programs with a unified method for path-searching: finding files and resources that those programs needed during the course of execution. TeX and related programs are designed to run on very many different platforms (Windows, Linux, Mac&#8230;) and one of the keys to doing this successfully is ensure that the underlying source code from which they are built is as platform-independent as is possible to achieve. <\/p>\n<p>So, in essence, Kpathsea is a path-searching library which is built into the TeX executable file (&#8220;TeX engine&#8221;) to provide unified methods for path-searching (finding files) that will work on many different computer platforms. When looking for font metric files, .tex files, .sty files, graphics and many other file resources, the &#8220;TeX engine&#8221; (e.g., LuaTeX) is using the Kpathsea library to find what it needs to typeset your document.<\/p>\n<blockquote><p><strong>LuaTeX offers an alternative: a primer<\/strong><br \/>\nFor LuaTeX this is just one part of the story. With LuaTeX you can implement your own Lua code to replace the Kpathsea file searching methods via LuaTeX&#8217;s &#8220;callback&#8221; methods. That&#8217;s for another day, here we&#8217;ll stick to using Kpathsea. If you are interested to read more about the powerful LuaTeX callbacks, consult <a href=\"http:\/\/www.luatex.org\/svn\/trunk\/manual\/luatexref-t.pdf\">The LuaTeX Reference Manual<\/a>.\n<\/p><\/blockquote>\n<h3>Kpathsea, <code>texmf.cnf<\/code> and environment variables<\/h3>\n<p>So, at long last you may say :-), we&#8217;ve finally reached the point where the various components start to come together.<\/p>\n<ul>\n<li><code>texmf.cnf<\/code> is the name given to the <a href=\"http:\/\/www.tug.org\/texinfohtml\/kpathsea.html#Config-files\">runtime configuration files<\/a> used by the Kpathsea <a href=\"http:\/\/www.tug.org\/texinfohtml\/kpathsea.html#Path-searching\">path-searching<\/a> library to locate resources (find files) on your computer and tell the &#8220;TeX engine&#8221;, including LuaTeX, where the &#8220;TeX engine&#8221; can locate the file(s) it needs in order to typeset your document.<\/li>\n<li>a TeX installation may use multiple <code>texmf.cnf<\/code> files to configure the installation. The use of multiple <code>texmf.cnf<\/code> files is discussed in the main Kpathsea documention.<\/li>\n<li>In addition to using <code>texmf.cnf<\/code> files, Kpathsea also uses environment variables to find resources. In essence, Kpathsea uses a mixture of environment variables and values stored in <code>texmf.cnf<\/code> files as a way to locate resources.<\/li>\n<\/ul>\n<h4>Kpathsea also sets environment variables<\/h4>\n<p>In addition to reading environment variables from your computer, Kpathsea also<br \/>\n<a href=\"http:\/\/www.tug.org\/texinfohtml\/kpathsea.html#Calling-sequence\"><em>sets<\/em><\/a> some environment variables<\/a> too: SELFAUTOLOC, SELFAUTODIR and SELFAUTOPARENT to the location, parent and grandparent directory of the executable (LuaTeX in our case).\n<\/ul>\n<h5>A simple example<\/h5>\n<p>If you are reading this and already have a working LuaTeX installation, the following LuaTeX example will typeset the values of SELFAUTOLOC, SELFAUTODIR and SELFAUTOPARENT from your LuaTeX configuration. <\/p>\n<pre>\\documentclass[11pt,twoside]{article}\r\n\\begin{document}\r\n\\pagestyle{empty}\r\n\\let\\temp\\\\%\r\n\\let\\\\\\relax\r\n\\directlua{\r\n         tex.print(\"SELFAUTOLOC = \"..os.getenv(\"SELFAUTOLOC\")..\"\\\\par\")\r\n         tex.print(\"SELFAUTODIR = \"..os.getenv(\"SELFAUTODIR\")..\"\\\\par\") \r\n         tex.print(\"SELFAUTOPARENT = \"..os.getenv(\"SELFAUTOPARENT\")..\"\\\\par\")  \r\n}\r\n\\end{document}<\/pre>\n<p>I have a working LuaTeX installation but copied the luatex.exe file to a directory<\/p>\n<p><code>c:\\luatexblog\\dir1\\dir2\\luatex.exe<\/code><\/p>\n<p>Putting the above LuaTeX code into a file called <code>test.tex<\/code> produced <a href=\"https:\/\/www.readytext.co.uk\/files\/test.pdf\">this pdf file<\/a>, showing that<\/p>\n<p><code>SELFAUTOLOC = c:\/luatexblog\/dir1\/dir2<br \/>\nSELFAUTODIR = c:\/luatexblog\/dir1<br \/>\nSELFAUTOPARENT = c:\/luatexblog<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Parts 1, 2 and 2a I made reference to such things as &#8220;environment variables&#8221; and a file called texmf.cnf. I this section of the tutorial I will try to bring these concepts together and get down to some practical details. But first we need to set the scene with a very important topic: Kpathsea. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,30],"tags":[],"class_list":["post-398","post","type-post","status-publish","format-standard","hentry","category-luatex-installing-on-windows","category-minimal-tex-system"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=398"}],"version-history":[{"count":38,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/398\/revisions"}],"predecessor-version":[{"id":3400,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/398\/revisions\/3400"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}