{"id":642,"date":"2011-01-25T20:36:55","date_gmt":"2011-01-25T20:36:55","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=642"},"modified":"2014-07-23T12:47:36","modified_gmt":"2014-07-23T12:47:36","slug":"a-minimal-luatex-setup-on-windows-part-6-final","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=642","title":{"rendered":"A minimal LuaTeX setup on Windows (Part 6: final)"},"content":{"rendered":"<p>Well, it feels like it has taken a lot of writing to get to this, the final Part of <em><a href=\"https:\/\/www.readytext.co.uk\/?cat=8\">A minimal LuaTeX setup on Windows<\/a><\/em>. At the end of Part 5 we had discussed creating a minimal TDS-compliant directory structure to contain the file types we need to install for a minimal plain TeX setup:<\/p>\n<ul>\n<li>TeX Font Metric files (extension <code>.tfm<\/code>)<\/li>\n<li>Font encoding files (extension <code>.enc<\/code>)<\/li>\n<li>Glyph data files (extension <code>.pfb<\/code>, on Windows)<\/li>\n<li>The plain TeX format file (extension <code>.fmt<\/code>)<\/li>\n<li>The plain TeX source files (plain.tex and hyphen.tex)<\/li>\n<li><code>.map<\/code> files (specifically for pdfTeX)<\/li>\n<\/ul>\n<p>We decided on a minimal TDS-compliant directory, starting with c:\\luatexblog\\texmf. Considering just the fonts, they will be located in subdirectories of <code>c:\\luatexblog\\texmf<\/code>. We&#8217;ll create a set of directories which follow the structure:<\/p>\n<p>c:\\luatexblog\\texmf\\fonts\\[type]\\[supplier]\\[typeface]<\/p>\n<p>Where [type] will be <\/p>\n<ul>\n<li><strong>tfm<\/strong>:  for <code>.tfm<\/code> files (TeX font metrics)<\/li>\n<li><strong>type1<\/strong>: for <code>.pfb<\/code> files (Printer Font Binary)<\/li>\n<\/ul>\n<p>Where [supplier] will be <strong>public<\/strong> (i.e., for free fonts) and [typeface] will simply be <strong>cm<\/strong> (for Computer Modern). In addition, under c:\\luatexblog\\texmf\\fonts\\ we&#8217;ll need to create directories for <\/p>\n<ul>\n<li><strong>map<\/strong>: for <code>.map<\/code> files (pdfTeX and LuaTeX font mapping files)<\/li>\n<li><strong>enc<\/strong>: for <code>.enc<\/code> files (font encoding)<\/li>\n<\/ul>\n<p>Finally, we directories to contain <\/p>\n<ul>\n<li>plain TeX source files (<code>plain.tex<\/code> and <code>hyphen.tex<\/code>)<\/li>\n<li>the plain TeX <code>.fmt<\/code> file<\/li>\n<li>the <code>texmf.cnf<\/code> file that we&#8217;ll write for Kpathsea<\/li>\n<\/ul>\n<p>Going back to the Kpathsea documentation which gives a <a href=\"http:\/\/www.tug.org\/texinfohtml\/kpathsea.html#TeX-directory-structure \">nice example of a skeleton TDS<\/a>, you should create a directory structure that looks something like this:<\/p>\n<p><img decoding=\"async\" src=\"..\/files\/minimaltexmf.png\" width=\"35%\"><\/img><\/p>\n<p>Note that if you add more <code>.pfb<\/code> files under the directory <code>c:\\luatexblog\\texmf\\fonts\\type1<\/code> then it is best practice to create a new subdirectory whose name reflects the supplier, for example I have added &#8220;adobe&#8221; as an example. Under each supplier you add a name for the typeface, e.g., utopia, and that&#8217;s where you would put the <code>.pfb<\/code> files:<\/p>\n<p><code>c:\\luatexblog\\texmf\\fonts\\type1\\adobe\\utopia\\*.pfb<\/code><\/p>\n<p>Here is where we will put the various files we need.<\/p>\n<table border=\"0\" >\n<tr>\n<th>File type<\/th>\n<th>TDS file path<\/th>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>.tfm<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\fonts\\tfm\\public\\cm\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>.pfb<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\fonts\\type1\\public\\cm\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>.enc<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\fonts\\enc\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>.map<\/code> <\/td>\n<td>c:\\luatexblog\\texmf\\fonts\\map\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>plain.tex<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\tex\\plain\\base\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>hyphen.tex<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\tex\\generic\\hyphen\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>texmf.cnf<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\web2c\\<\/td>\n<\/tr>\n<tr>\n<td width=\"30%\"><code>plain.fmt<\/code><\/td>\n<td>c:\\luatexblog\\texmf\\web2c\\<\/td>\n<\/tr>\n<\/table>\n<h3>Filling these directories with files<\/h3>\n<p>Clearly, we will be generating <code>plain.fmt<\/code> and you saw in Part 5 where to get <code>plain.tex<\/code> and <code>hyphen.tex<\/code>. We will shortly be writing <code>texmf.cnf<\/code> by hand, so that leaves the following files to be obtained from somewhere:<\/p>\n<ul>\n<li>TeX Font Metric files (<code>.tfm<\/code>)<\/li>\n<li>Font encoding files (<code>.enc<\/code>)<\/li>\n<li>Glyph data files (<code>.pfb<\/code>, on Windows)<\/li>\n<li><code>.map<\/code> files (specifically for pdfTeX)<\/li>\n<\/ul>\n<h4>But firstly, a note of caution<\/h4>\n<p>TeX Font Metric files (for text fonts) need to used and obtained with a little caution because they are tied to a specific font encoding. In general, and particularly with plain TeX (which assumes a certain encoding) you cannot just use them without knowing how they were encoded when they were created. For example, the afm2tfm.exe utility available from TeX Live (converts Adobe&#8217;s AFM files to TeX&#8217;s <code>.tfm<\/code>)  can be given an encoding vector on its command line. Certainly, LaTeX has far more flexibility with encodings but plain TeX is rather less versatile.<\/p>\n<h5>Obtaining the <code>.tfm<\/code> files for the Computer Modern fonts<\/h5>\n<p>Using the method of <a href=\"https:\/\/www.readytext.co.uk\/?p=365\">browsing TeX Live<\/a>, you can access the Computer Modern <code>.tfm<\/code> files here:<\/p>\n<p>svn:\/\/tug.org\/texlive\/trunk\/Master\/texmf-dist\/fonts\/tfm\/public\/cm<\/p>\n<blockquote><p>\n<strong>One oddity: <code>manfnt.tfm<\/code><\/strong><br \/>\nThis <code>.tfm<\/code> is required to build the plain TeX format and you can get it <a href=\"http:\/\/www.ctan.org\/tex-archive\/fonts\/cm\/tfm\/\">here<\/a>.\n<\/p><\/blockquote>\n<h5>Obtaining the <code>.pfb<\/code> files for the Computer Modern fonts<\/h5>\n<p>The American Mathematical Society provides the Computer Modern fonts in Adobe Type 1 format, which can be downloaded as part of their <a href=\"http:\/\/www.ams.org\/publications\/authors\/tex\/amsfonts\">AMSFonts collection<\/a>. <\/p>\n<h5>Obtaining the <code>.map<\/code> file for pdfTeX (<code>pdftex.map<\/code>)<\/h5>\n<p>I have created an absolutely minimal <code>pdftex.map<\/code> file which you can <a href = \"https:\/\/www.readytext.co.uk\/files\/pdftexmap.zip\">download from this site<\/a>.<\/p>\n<h5>Obtaining the <code>.enc<\/code> files<\/h5>\n<p>In short, for this ultra-minimal setup you won&#8217;t need any so we&#8217;ll ignore them.<\/p>\n<h5>What about <code>luatex.exe<\/code>?<\/h5>\n<p><a href=\"http:\/\/foundry.supelec.fr\/gf\/project\/luatex\/frs\/\">Download a copy of the latest binary<\/a> and copy it to <code>c:\\luatexblog\\luatex.exe<\/code>.<\/p>\n<blockquote><p>\n<strong>Note: edit your <code>PATH<\/code><\/strong><br \/>\nDon&#8217;t forget that you will need to add <code>c:\\luatexblog<\/code> to your computer&#8217;s <code>PATH<\/code> environment variable otherwise your PC won&#8217;t be able to find <code>luatex.exe<\/code> when you try to run it!\n<\/p><\/blockquote>\n<h3>Kpathsea and <code>texmf.cnf<\/code><\/h3>\n<p>We are nearly finished! All we now need to do is tell Kpathsea where to locate the various files in our minimal TDS tree and we do this through a <code>texmf.cnf<\/code> file that we must save to <code>c:\\luatexblog\\texmf\\web2c\\texmf.cnf<\/code>.<\/p>\n<p>If you look at the <code>texmf.cnf<\/code> file supplied with TeX Live it looks quite daunting and complex because Kpathsea&#8217;s powerful searching algorithms allow you to construct quite complex expressions to describe paths and directory structures. Kpathsea allows you to create TeX installations of quite some complexity with multiple TDS trees being used for different purposes. We will not even touch a tiny fraction of Kpathsea&#8217;s power and flexibility. <\/p>\n<p>See, for example<\/p>\n<ul>\n<li>Michael J Downes: <a href=\"http:\/\/tug.org\/TUGboat\/Articles\/tb22-3\/tb72downes.pdf\">Managing Multiple TDS Trees<\/a><\/li>\n<li>Siep Kroonenberg: <a href=\"http:\/\/www.ntg.nl\/maps\/27\/17.pdf\">Juggling texmf trees<\/a><\/li>\n<\/ul>\n<p>Describing the features of Kpathsea in detail is far beyond the scope of this post, perhaps one for another day. Interested readers should refer to the <a href=\"http:\/\/www.tug.org\/texinfohtml\/kpathsea.html#Top\">Kpathsea documentation<\/a> and the <code>texmf.cnf<\/code> file available on theTeX Live repository &ndash; it contains very many helpful comments. For those who are comfortable reading C, there is a lot of additional information in the comments scattered throughout the Kpathsea source code. Happy reading!<\/p>\n<h4>Final steps<\/h4>\n<ol>\n<li>\n\tSet an environment variable called <code>TEXMFCNF<\/code> which tells Kpathsea where to start looking for your configuration files (<code>texmf.cnf<\/code>). For our installation it should be set to<\/p>\n<ul>\n<li><code>TEXMFCNF=c:\\luatexblog\\texmf\\web2c\\<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Enable Kpathsea debugging environment variables:\n<ul>\n<li><code>KPATHSEA_DEBUG_OUTPUT=c:\/kspsluatex.log<\/code><\/li>\n<li><code>KPATHSEA_DEBUG=-1<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Put the following into a text file called <code>texmf.cnf<\/code> and save it to<br \/>\n<code>c:\\luatexblog\\texmf\\web2c<\/code><\/p>\n<pre><code>\r\n<del datetime=\"2011-01-26T20:00:43+00:00\">          WEB2C=c:\/luatexblog\/texmf\/web2c\r\n          TEXINPUTS = .\/:c:\/luatexblog\/texmf\/tex\/\/\r\n          TEXFONTMAPS = c:\/luatexblog\/texmf\/fonts\/map\r\n          TFMFONTS = c:\/luatexblog\/texmf\/fonts\/tfm\/\/\r\n          TEXFORMATS=c:\/luatexblog\/texmf\/web2c\r\n          T1FONTS = c:\/luatexblog\/texmf\/fonts\/type1\/\/\r\n          ENCFONTS = c:\/luatexblog\/texmf\/fonts\/enc<\/code><\/del>\r\n\r\n<strong>Erratum:<\/strong> Apologies, the above <code>texmf.cnf<\/code> is not correct (although it works). A far better way is as follows.\r\n\r\n          TEXMF=$SELFAUTOLOC\/texmf\r\n          WEB2C=$TEXMF\/web2c\r\n          TEXINPUTS = .;$TEXMF\/tex\/\/\r\n          TEXFONTMAPS = $TEXMF\/fonts\/map\r\n          TEXFORMATS=$TEXMF\/web2c\r\n          TFMFONTS = $TEXMF\/fonts\/tfm\/\/\r\n          T1FONTS = $TEXMF\/fonts\/type1\/\/\r\n          ENCFONTS = $TEXMF\/fonts\/enc\r\n\r\n\r\n<\/pre>\n<\/li>\n<\/ol>\n<h5>Summary of these <code>texmf.cnf<\/code> variables<\/h5>\n<p>Source: <a href=\"http:\/\/sarovar.org\/docman\/view.php\/106\/64\/pdftex-a.pdf.pdf\">The pdfTeX Manual<\/a><\/p>\n<ul>\n<li><code>$SELFAUTOLOC<\/code>: An environment variable set by Kpathsea (when it starts running) which gives the location of the executable; i.e., <code>c:\\luatexblog<\/code> for <code>luatex.exe<\/code> as that is where we put it.<\/li>\n<li><code>TEXINPUTS<\/code>: This variable specifies where pdfTeX (and LuaTeX) finds its input files. Image files are considered input files and searched for along this path.<\/li>\n<li><code>TEXFONTMAPS<\/code>: Search path for font map <code>(.map)<\/code> files.<\/li>\n<li><code>TFMFONTS<\/code>: Search path for font metric (<code>.tfm<\/code>) files.<\/li>\n<li><code>TEXFORMATS<\/code>: Search path for format (<code>.fmt<\/code>) files.<\/li>\n<li><code>T1FONTS<\/code>: Search path for Type 1 font files (<code>.pfa<\/code> and <code>.pfb<\/code>). <\/li>\n<li><code>ENCFONTS<\/code>: Search path for encoding (<code>.enc<\/code>) files.<\/li>\n<\/ul>\n<h5>General notes<\/h5>\n<ul>\n<li>Kpathsea uses forward slashes &#8220;\/&#8221; <\/li>\n<li>In our example, <code>TEXINPUTS <\/code>starts with &#8220;<code>.<\/code>&#8221; and has a second path &#8220;<code>c:\/luatexblog\/texmf\/tex\/\/<\/code>&#8221; (separated by &#8220;<code>;<\/code>&#8220;) which ends in &#8220;<code>\/\/<\/code>&#8220;.\n<ul>\n<li>&#8220;<code>.<\/code>&#8220;: this means &#8220;the current directory&#8221;.<\/li>\n<li>The &#8220;<code>\/\/<\/code>&#8221; means search recursively into the directory<\/li>\n<li>&#8220;<code>;<\/code>&#8221; is a separator for Kpathsea &#8220;path elements&#8221;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<blockquote><p>\n<strong>Something I have ignored:<code> ls-R<\/code> databases<\/strong><br \/>\nKpathsea can use an externally-built filename database file named <code>ls-R<\/code> that maps files to directories, thus avoiding the need to exhaustively search the disk. See the <a href=\"http:\/\/www.tug.org\/texinfohtml\/kpathsea.html#Filename-database\">Kpathsea documentation<\/a> for more detail.\n<\/p><\/blockquote>\n<h4>Running luatex<\/h4>\n<p>If you type <code>luatex --help<\/code> at the DOS prompt you&#8217;ll see a number of command-line options. But of these only 4 are of immediate interest:<\/p>\n<table border=\"0\">\n<tr>\n<td><code> --fmt=FORMAT<\/code> <\/td>\n<td>load the format file <code>FORMAT<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>--ini<\/code><\/td>\n<td>be iniluatex, for dumping formats<\/td>\n<\/tr>\n<tr>\n<td><code> --output-directory=DIR<\/code><\/td>\n<td>use DIR as the directory to write files to<\/td>\n<\/tr>\n<tr>\n<td><code> --output-format=FORMAT<\/code><\/td>\n<td>use FORMAT for job output; FORMAT is &#8216;dvi&#8217; or &#8216;pdf&#8217;<\/td>\n<\/tr>\n<\/table>\n<p>Note that when you run LuaTeX it will write the PDF file, and maybe others, to the current working directory unless you specify an another directory using <code>--output-directory=DIR<\/code><\/p>\n<h5>Generating <code>plain.fmt<\/code><\/h5>\n<p>We&#8217;ll use the fact that LuaTeX will write to the current directory unless told otherwise. Start a DOS prompt and change the directory to where we want the <code>plain.fmt<\/code> file to be located:<\/p>\n<p><code>c:\\luatexblog\\texmf\\web2c<\/code><\/p>\n<p>Run the command line:<\/p>\n<p><code>c:\\luatexblog\\texmf\\web2c&gt; luatex --ini plain.tex \\dump<\/code><\/p>\n<p>You should see something like the following, and a file called <code>plain.fmt<\/code> created in<br \/>\n<code>c:\\luatexblog\\texmf\\web2c<\/code><\/p>\n<p><code>This is LuaTeX, Version beta-0.65.0-2010121314 (rev 4033)  (INITEX)<br \/>\n(c:\/luatexblog\/texmf\/tex\/plain\/base\/plain.tex<br \/>\nPreloading the plain format: codes, registers, parameters, fonts, more fonts,<br \/>\nmacros, math definitions, output routines, hyphenation<br \/>\n(c:\/luatexblog\/texmf\/tex\/generic\/hyphen\/hyphen.tex))<br \/>\nBeginning to dump on file plain.fmt<br \/>\n (format=plain 2011.1.25)<\/p>\n<p>...<br \/>\n...<br \/>\n...<\/p>\n<p><\/code><\/p>\n<h4> TeXing our first file<\/h4>\n<p>Create a directory called <code>myfiles<\/code> under <code>c:\\luatexblog<\/code> and change to that directory.<\/p>\n<p><code>c:\\luatexblog\\myfiles&gt;<\/code><\/p>\n<p>Grab any plain TeX example from the web (for example <a href=\"http:\/\/www.combinatorics.org\/Information\/plain.html\">http:\/\/www.combinatorics.org\/Information\/plain.html<\/a>)<\/p>\n<p>Save it to a text file <code>c:\\luatexblog\\myfiles\\test.tex<\/code><\/p>\n<p>Run the command  <\/p>\n<p><code>c:\\luatexblog\\myfiles&gt; luatex --fmt=plain test.tex<\/code><\/p>\n<p>You should see<\/p>\n<p><code>c:\\luatexblog\\myfiles&gt; luatex --fmt=plain test.tex<br \/>\nThis is LuaTeX, Version beta-0.65.0-2010122301<br \/>\n(.\/test.tex 1. Introduction.  [1] )<br \/>\nOutput written on test.dvi (1 page, 2432 bytes).<br \/>\nTranscript written on test.log.<\/code><\/p>\n<p>With a file <code>test.dvi<\/code> output in <code>c:\\luatexblog\\myfiles<\/code><\/p>\n<p>Now run the command <\/p>\n<p><code>c:\\luatexblog\\myfiles&gt; luatex --fmt=plain  --output-format=pdf test.tex<\/code><\/p>\n<p>You should see<\/p>\n<p><code>c:\\luatexblog\\myfiles&gt;luatex --fmt=plain --output-format=pdf test.tex<br \/>\nThis is LuaTeX, Version beta-0.65.0-2010122301<br \/>\n(.\/test.tex 1. Introduction.  [1{c:\/luatexblog\/texmf\/fonts\/map\/pdftex.map}] )<br \/>\n&lt;c:\/luatexblog\/texmf\/fonts\/type1\/public\/cm\/cmbx10.PFB&gt;&lt;c:\/luatexblog\/texmf\/fonts\/<br \/>\ntype1\/public\/cm\/cmcsc10.PFB&gt;&lt;c:\/luatexblog\/texmf\/fonts\/type1\/public\/cm\/cmr10.PF<br \/>\nB&gt;&lt;c:\/luatexblog\/texmf\/fonts\/type1\/public\/cm\/cmr12.PFB&gt;&lt;c:\/luatexblog\/texmf\/fon<br \/>\nts\/type1\/public\/cm\/cmtt10.PFB&gt;<br \/>\nOutput written on test.pdf (1 page, 70507 bytes).<br \/>\nTranscript written on test.log.<\/code><\/p>\n<p>With a file <code>test.pdf<\/code> output in <code>c:\\luatexblog\\myfiles<\/code><\/p>\n<h5>Conclusion<\/h5>\n<p>Over these 6 tutorials I have tried to cover, in general terms, some of the &#8220;TeX landscape&#8221; and to equip you with enough information to begin building your own LuaTeX test environment, should you wish to. Of course, I have omitted vast amounts of technical detail in the interest of simplicity and building &#8220;a conceptual framework&#8221; for your own investigations. I hope that I have not made any serious errors but if anyone spots some, do please let me know so that I can release corrected and updated posts. <\/p>\n<p>I hope that somewhere &#8220;out on the web&#8221; someone has enjoyed these and found them to be useful.<\/p>\n<p>Cheers <\/p>\n<p>Graham!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, it feels like it has taken a lot of writing to get to this, the final Part of A minimal LuaTeX setup on Windows. At the end of Part 5 we had discussed creating a minimal TDS-compliant directory structure to contain the file types we need to install for a minimal plain TeX setup: [&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-642","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\/642","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=642"}],"version-history":[{"count":84,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":3403,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/3403"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}