[luatex] invoking a lua script in TeX

Dirk Laurie dpl at sun.ac.za
Tue Apr 12 11:57:49 CEST 2011

On Tue, Apr 12, 2011 at 01:33:43AM +0200, Bob Tennent wrote:
> 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.
>
http://wiki.luatex.org/index.php/Writing_Lua_in_TeX

>
> 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.
>
> Thanks for any help you could provide.

\def\musixflex{ \ifx\undefined\directlua \else \directlua {
musixflx = kpse.find_file("musixflx.lua")
if musixflx then dofile(musixflx) end } \fi }

If you put \musixflex immediately after \endmuflex in your
TeX file, and you are processing the file with luatex, and
musixflx.lua is somewhere in your TeX path, then musixflx.lua
will be run on your file.  This reduces the three-pass process
to a two-pass process.

It should be possible to incorporate this macro call somewhere
in musixtex.tex.

Dirk