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


Hopefully useful example of \directlua{} expansion

The following example may help to understand a little more about \directlua{} expansion.




function Hello(str)



\hellofromTeX{"Hello World"}

Here's how it works.
Code within \directlua{} is expanded according to TeX rules and then sent to the Lua interpreter. In the above, LuaTeX "sees" \xx\yy#1\zz and expands it as follows:

\xx --> Hello
\yy --> (
#1 --> "Hello World"
\zz --> )

After this expansion, the code is fed to the Lua interpreter, which sees Hello("Hello World") and executes

function Hello(str)

The function tex.print("Hello World") is called and typesets some text.

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

Sorry, the comment form is closed at this time.

No trackbacks yet.