[luatex] Building a PDF with Lua code, without a TeX stub

Steve Litt slitt at troubleshooters.com
Fri Oct 21 16:31:03 CEST 2016


On Thu, 20 Oct 2016 11:55:49 +0530
Deepak Jois <deepak.jois at gmail.com> wrote:

> Hi
> I would like to invoke the LuaTeX interpreter with a Lua file which
> does the node building etc, and then calls something like
> tex.shipout(), which can generate a PDF. I am aware of the --lua flag,
> but the file passed to that flag executes before the TeX engine is
> fully initialised. So that’s not what I am looking for
> 
> For example, lets say I have a Lua file with code:
> 
> <code>
> -- Page settings
> tex.pagewidth = "210mm"
> tex.pageheight = "297mm"
> tex.hsize = "210mm"
> 
> -- Set the paragraph indentation
> tex.parindent = "20pt"
> 
> tex.sprint("hello world")
> </code>
> 
> and I want to generate a PDF from it directly using the luatex
> command. I cannot seem to do that right now, and I require a stub TeX
> file like this.
> 
> <code>
> \outputmode=1 % this could be avoided if I pass --output-format=pdf
> \directlua{dofile('code.lua')}
> \bye
> </code>
> 
> Questions:
> 
> - Is there a way to avoid creating the stub TeX file?
> 
> - If not, is it something worth adding (or possible to add) as a
> feature to the LuaTeX program?
> 
> Deepak

Hi Deepak,

You could always have your Lua code create the stub as a temp file, and
remove it when done. I know that's an ugly kludge, but it *is* one way
to do it.

SteveT

Steve Litt 
September 2016 featured book: Twenty Eight Tales of Troubleshooting
http://www.troubleshooters.com/28





More information about the luatex mailing list