STM publishing: tools, technologies and change A WordPress site for STM Publishing

26Jan/11Off

Enabling LuaTeX’s use of \pdfoutput

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 "switching on" these new commands, LuaTeX supports just the original TeX82 primitives plus the \directlua{...} command. It does not even understand the pdfTeX primitive \pdfoutput which enables choosing between PDF and DVI output via your TeX file, rather than LuaTeX's command line options. For example, before enabling the full LuaTeX command set, if you run the following plain TeX file (say demo.tex):

\pdfoutput=1 %select PDF output
Hello \TeX
\bye

luatex --fmt=plain demo.tex


c:\luatexblog\myfiles&g>luatex --fmt=plain demo.tex
This is LuaTeX, Version beta-0.65.0-2010121314 (rev 4033)
(./demo.tex
! Undefined control sequence.
l.1 \pdfoutput
=1 %select PDF output
?

Hmmm, something is strange because LuaTeX is based on pdfTeX and that, of course, understands \pdfoutput=1.

Creating a new format: luaplain

So, how do we get access to \pdfoutput? 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 "luaplain" because it is no longer Knuth's original plain TeX. The task is to create the luaplain.fmt file so that we can access the full power of LuaTeX using plain TeX (later we will extend this to LaTeX).

  1. Within the minimal TDS tree (see Part 6), create a directory called c:\luatexblog\texmf\tex\luaplain\
  2. Create a TeX file called luaplain.tex containing the following TeX code: \input plain
    \directlua {tex.enableprimitives('', tex.extraprimitives())}
  3. Start a DOS session and change the current directory to c:\luatexblog\texmf\web2c\ (which is where we store .fmt files, as we want to create luaplain.fmt).
  4. Type the command:
    c:\luatexblog\texmf\web2c>luatex --ini luaplain.tex \dump
  5. All being well, you should see the file luaplain.fmt created in c:\luatexblog\texmf\web2c\

Back to our example (demo.tex) which failed under plain TeX

\pdfoutput=1 %select PDF output
Hello \TeX
\bye

Now run LuaTeX with the command line luatex --fmt=luaplain demo.tex and you should see something like this:

c:\luatexblog\myfiles>luatex --fmt=luaplain demo.tex
This is LuaTeX, Version beta-0.65.0-2010121314 (rev 4033)
(./demo.tex [1{c:/luatexblog/texmf/fonts/map/pdftex.map}] )<c:/luatexblog/texmf
/fonts/type1/public/cm/cmr10.PFB>
Output written on demo.pdf (1 page, 11487 bytes).
Transcript written on demo.log.

Success!

Filed under: Examples Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

No trackbacks yet.