# [luatex] invoking a lua script in TeX

Bob Tennent rdt at cs.queensu.ca
Tue Apr 12 01:33:43 CEST 2011

```Hi. I'm trying to integrate a three-pass process into a single luatex
process. I believe \directlua and tex.print or some variant can provide
the desired functionality but I'm not a TeX expert and the documentation
I've seen so far doesn't seem to be directly relevant. I'd be very
grateful for some assistance or pointers to relevant documentation.

The current work flow is as follows:

1. tex basename.tex
produces a dvi file etc. as usual plus a data file basename.mx1

2. musixflx basename
reads basename.mx1, does some calculations, and outputs basename.mx2

3. tex basename (in the presence of basename.mx2)
reads basename.mx2 and produces a modified dvi etc.

Traditionally, musixflx has been a platform-dependent binary compiled
from source code in C. But recently, musiflx.c has been translated to
a functionally equivalent musixflx.lua; that is, the second pass can be
achieved by

lua musixflx.lua basename

musixflx.lua is the script I hope can be invoked from within a TeX
macro package after generation of the .mx1 file; then, I would want to
re-invoke TeX from the Lua script after generation of the .mx2 file.

It might be possible and/or desirable not to have to use auxiliary files
basename.mx1 and basename.mx2, but I would consider that a refinement
that could be deferred if it is problematic.