{"id":727,"date":"2011-01-26T22:45:20","date_gmt":"2011-01-26T22:45:20","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=727"},"modified":"2013-11-28T09:00:14","modified_gmt":"2013-11-28T09:00:14","slug":"enabling-luatexs-use-of-pdfoutput","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=727","title":{"rendered":"Enabling LuaTeX&#8217;s use of \\pdfoutput"},"content":{"rendered":"<p>In the tutorial series <em>A minimal LuaTeX setup on Windows<\/em> I showed how to get started with a very basic LuaTeX setup for plain TeX. Actually, it is so minimal that we have not even enabled the many new primitives (low-level commands) that the LuaTeX engine provides. Without &#8220;switching on&#8221; these new commands, LuaTeX supports just the original TeX82 primitives plus the <code>\\directlua{...}<\/code> command. It does not even understand the pdfTeX primitive <code>\\pdfoutput<\/code> which enables choosing between PDF and DVI output via your TeX file, rather than LuaTeX&#8217;s command line options. For example, before enabling the full LuaTeX command set, if you run the following plain TeX file (say <code>demo.tex<\/code>):<\/p>\n<p><code>\\pdfoutput=1 %select PDF output<br \/>\nHello \\TeX<br \/>\n\\bye<\/code><\/p>\n<p><code>luatex --fmt=plain demo.tex<\/code><\/p>\n<p><code><br \/>\nc:\\luatexblog\\myfiles&amp;g&gt;luatex --fmt=plain demo.tex<br \/>\nThis is LuaTeX, Version beta-0.65.0-2010121314 (rev 4033)<br \/>\n(.\/demo.tex<br \/>\n! Undefined control sequence.<br \/>\nl.1 \\pdfoutput<br \/>\n=1 %select PDF output<br \/>\n?<\/code><\/p>\n<p>Hmmm, something is strange because LuaTeX is based on pdfTeX and that, of course, understands <code>\\pdfoutput=1<\/code>.<\/p>\n<h4>Creating a new format: luaplain<\/h4>\n<p>So, how do we get access to <code>\\pdfoutput<\/code>? One way to do this is to create a new format, derived from plain TeX, but which contains a little bit of code to enable the full LuaTeX command set. We will call this format &#8220;luaplain&#8221; because it is no longer Knuth&#8217;s original plain TeX. The task is to create the <code>luaplain.fmt<\/code> file so that we can access the full power of LuaTeX using plain TeX (later we will extend this to LaTeX).<\/p>\n<ol>\n<li>Within the minimal TDS tree (see <a href=\"https:\/\/www.readytext.co.uk\/?p=642\">Part 6<\/a>), create a directory called <code>c:\\luatexblog\\texmf\\tex\\luaplain\\<\/code><\/li>\n<li>Create a TeX file called <code>luaplain.tex<\/code> containing the following TeX code:<code> \\input plain<br \/>\n\\directlua {tex.enableprimitives('', tex.extraprimitives())}<\/code><\/li>\n<li>Start a DOS session and change the current directory to <code>c:\\luatexblog\\texmf\\web2c\\<\/code> (which is where we store <code>.fmt<\/code> files, as we want to create <code>luaplain.fmt<\/code>).<\/li>\n<li>Type the command:<br \/>\n<code>c:\\luatexblog\\texmf\\web2c&gt;luatex --ini luaplain.tex \\dump<\/code><\/li>\n<li>All being well, you should see the file <code>luaplain.fmt<\/code> created in <code>c:\\luatexblog\\texmf\\web2c\\<\/code><\/li>\n<\/ol>\n<p>Back to our example (<code>demo.tex<\/code>) which failed under plain TeX<\/p>\n<p><code>\\pdfoutput=1 %select PDF output<br \/>\nHello \\TeX<br \/>\n\\bye<\/code><\/p>\n<p>Now run LuaTeX with the command line <code>luatex --fmt=<strong>luaplain<\/strong> demo.tex<\/code> and you should see something like this:<\/p>\n<p><code>c:\\luatexblog\\myfiles&gt;luatex --fmt=luaplain demo.tex<br \/>\nThis is LuaTeX, Version beta-0.65.0-2010121314 (rev 4033)<br \/>\n(.\/demo.tex [1{c:\/luatexblog\/texmf\/fonts\/map\/pdftex.map}] )&lt;c:\/luatexblog\/texmf<br \/>\n\/fonts\/type1\/public\/cm\/cmr10.PFB&gt;<br \/>\nOutput written on demo.pdf (1 page, 11487 bytes).<br \/>\nTranscript written on demo.log.<\/code><\/p>\n<p>Success!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the tutorial series A minimal LuaTeX setup on Windows I showed how to get started with a very basic LuaTeX setup for plain TeX. Actually, it is so minimal that we have not even enabled the many new primitives (low-level commands) that the LuaTeX engine provides. Without &#8220;switching on&#8221; these new commands, LuaTeX supports [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-examples"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/727","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=727"}],"version-history":[{"count":12,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":3248,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions\/3248"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}