[luatex] Lua long strings

Paul Isambert zappathustra at free.fr
Fri May 6 12:11:13 CEST 2011


Le 06/05/2011 12:06, Philipp Stephani a écrit :
> Am 06.05.2011 um 11:51 schrieb Dirk Laurie:
>
>> I'd like to define a Latex environment "verbatimlua" that allows:
>>
>> \begin{verbatimlua}
>> s = [[
>> A long Lua string containing special characters like \ and %,
>> with end-of-lines respected too.
>> ]]
>> print(s) -- all of s on the screen and in the log file
>> tex.print(string.format("%.5f",math.pi))) -- 3.14159 in the TeX output
>> \end{verbatimlua}
>>
>> I.e. it works like "verbatim" but the contents is passed to the Lua
>> engine instead.  Same as putting it in a file xxx.lua and saying
>> \directlua{ dofile"xxx" }
>>
>> I can't possibly be the first person who has tried and failed to do this.
>> Maybe someone has tried and succeeded?
> See the luacode package:
> http://ctan.org/pkg/luacode

Alternatively, if you want to do it by yourself, here's the cookbook: 
http://wiki.luatex.org/index.php/Writing_Lua_in_TeX (see the definition 
of \luacode in section « Special characters »).

Paul


More information about the luatex mailing list