When I read this from the manual a long time ago:

The \directlua command is expandable: the results of the LUA code
become effective immediately.

I could not make sense of it, and actually cannot up to day. What are
"the results of the LUA code"? What does "become effective" mean? Now
I now the answers to those questions but not because of the
explanation given there. The example provided does not help much
either. Note that this comes very soon in the manual. I propose the
following wording:

The \directlua command is expandable. Since it passes Lua code to the
Lua interpreter its expansion from the TeX viewpoint is usually empty.
However, there are some Lua functions that produce material to be read
by TeX, the so called print functions. The most simple use of these is
tex.print(<string> s). The characters of the string s will be placed
on TeX input buffer, that is, "before TeX's eyes" to be read by TeX
immediately. For example:

\count10=20
a\directlua{tex.print(tex.count[10]+5)}b

expands to

a25b

Here is another example:

$\pi = \directlua{tex.print(math.pi)}$

will result in

p = 3.1415926535898

Note that the expansion of \directlua is a sequence of characters, not
of tokens, contrary to all TeX commands. So formally speaking its
expansion is null, but places material on a pseudo-file to be
immediately read by TeX, as etex's \scantokens.

For a description of print functions look at section 4.13.10.

Regards,
Javier A. Múgica
_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-luatex

Reply via email to