[NTG-context] OT: Problem with writing macros into variables in LuaTeX
Jaroslav Hajtmar
hajtmar at gyza.cz
Sun Mar 18 14:15:18 CET 2012
Thanks Wolfgang,
these are very valuable tips for me for the future. I put them to
special document for later use. Thanks again for the valuable advice.
Jaroslav Hajtmar
Dne 18.3.2012 14:00, Wolfgang Schuster napsal(a):
> Am 18.03.2012 um 13:48 schrieb Jaroslav Hajtmar:
>
>
>> > Thanx Wolfgang.
>> >
>> > Thanks for the tip. I do too, but I did not know how to get into Lua code that the macro.
>>
> The one thing you have to know, when you pass a macro from TeX to Lua it is expanded.
>
> \def\foo{FOO}
>
> \directlua{myfuntion("\foo")}
>
> In this example the Lua function gets “FOO” as input and not “\foo” because the argument of \directlua is expanded, to prevent you need a function which prevents expansion.
>
> \directlua{myfunction("\string\foo")}
>
> Works only for the command after \string.
>
> \directlua{myfunction("\detokenize{\foo}")
>
> Converts \foo into tokens and Lua sees now \foo.
>
> \directlua{myfunction("\unexpanded{\foo}")
>
> Prevents the argument to be expanded and Lua gets \foo (there are differences compared with \detokenize but I forgot them)
>
> Wolfgang
>
More information about the ntg-context
mailing list