[luatex] Newbie question: how to stop TeX trying to interpret Lua?

luigi scarso luigi.scarso at gmail.com
Mon Apr 4 16:07:28 CEST 2011


On Mon, Apr 4, 2011 at 3:36 PM, Paul Isambert <zappathustra at free.fr> wrote:
>
>
> Le 04/04/2011 11:40, luigi scarso a écrit :
>>
>> On Mon, Apr 4, 2011 at 10:25 AM, Paul Isambert<zappathustra at free.fr>
>>  wrote:
>>
>>> Yes, because \TeX expands to harmless primitives (\kern, etc.), so
>>> tex.print
>>> actually sees is something like "T\kern-.1.667em....". Try replacing
>>> tex.print with texio.write_nl and you'll see. In other cases, though,
>>> expansion should be carefully controlled.
>>
>> True, in fact I though that one can replace
>> <<text>>
>> with
>> \directlua{tex.print( [=[<<text>>]=])}
>> assuming ASCII and the same catcode regime
>> but it's not true, even if I don't understand clearly why.
>>
>>
>> \bgroup
>> \initcatcodetable1
>> \catcode`\_=0
>> _TeX\TeX
>> \savecatcodetable1
>> \egroup
>>
>> %% ok
>> \directlua{tex.print(1, [=[_TeX\relax\TeX]=])}
>>
>> %% ok
>> \directlua{tex.print(1, [=[_TeX{}\TeX]=])}
>>
>> %% ok
>> \directlua{tex.print(1, [=[_TeX \TeX]=])}
>>
>>
>> %% wrong
>> %% \directlua{tex.print(1, [=[_TeX\TeX]=])}
>> %% ! Undefined control sequence.
>> %% l.1 _TeXT
>> %%         \kern
>
> Quite normal: \TeX is expanded in \directlua to "T\kern1.6667em etc.", so
> the string that is passed to the Lua interpreter and then back to TeX is
> "_TeXT\kern1.6667em etc." The underscore being an escape character here,
> _TeXT is an (unexisting) control sequence. Try:
>
> \directlua{tex.print(1, [=[_TeX\noexpand\TeX]=])}
>
> and \TeX will remain as it is, and the string passed back from Lua to TeX
> will be "_TeX\TeX", hence no error.


Sorry, wrong example. I wrote
>> assuming ASCII and the same catcode regime
so the code correct code should be

\bgroup
\catcode `\_=0
_TeX\TeX

\directlua{tex.print([=[_TeX\TeX]=])}
\egroup

\bye

In this sense
<<text>>
and
\directlua{tex.print([=[<<text>>]=])}
should always be the same .

-- 
luigi



More information about the luatex mailing list