[luatex] TeX scanner

luigi scarso luigi.scarso at gmail.com
Mon Oct 20 18:29:33 CEST 2014


\directlua {
    function followup(n)
        print(tex.box[n].list.width)
        print(tex.box[n].list.height)
        print(tex.box[n].list.depth)
        tex.print(tex.box[n].list.width  .. "\string\\par")
        tex.print(tex.box[n].list.height .. "\string\\par")
        tex.print(tex.box[n].list.depth  .. "\string\\par")
    end
}
\directlua {
    tex.print([[\string\setbox0=\string\hbox{foo}]])
    tex.print([[\string\directlua{followup(0)}]])
}

(credit: H. Hagen)


On Mon, Oct 20, 2014 at 5:16 PM, Andreas Matthias <
andreas.matthias at gmail.com> wrote:

> Is it possible to call the TeX scanner from within Lua?
>
> I would like to put a string into a box and then work on the node list.
> If the string were available on the TeX side I would
>
>   \setbox0\hbox{...}
>
> and the use it on the Lua side
>
>   tex.box[0]
>
> But what should I do if the string is generated on the Lua side and
> thus no available on the TeX side? Is it possible to call the TeX
> scanner to read this string?
>
>
> Ciao
> Andreas
>
>

\directlua {
    function followup(n)
        print(tex.box[n].list.width)
        print(tex.box[n].list.height)
        print(tex.box[n].list.depth)
        tex.print(tex.box[n].list.width  .. "\string\\par")
        tex.print(tex.box[n].list.height .. "\string\\par")
        tex.print(tex.box[n].list.depth  .. "\string\\par")
    end
}
\directlua {
    tex.print([[\string\setbox0=\string\hbox{foo}]])
    tex.print([[\string\directlua{followup(0)}]])
}

(the code is from H. Hagen)
-- 
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/luatex/attachments/20141020/7c325ce7/attachment.html>


More information about the luatex mailing list