# [luatex] How to pass a box from TeX to lua

Andreas Matthias andreas.matthias at gmail.com
Thu Jan 12 21:30:17 CET 2012

\directlua {%
function out(t)
x = node.vpack(t)
node.write(x)
end
}

\def\foo{%
\directlua {%
s = node.new(node.id('glyph'))
s.char = 97
s.font = 1
out(node.hpack(s))
}}
\foo

This code creates an hbox that is passed to function out' which
then packs everything into a vbox. Fine. But now I would like
to do the first part (creation of the hbox) in TeX and the second
part (creation of the vbox) in lua. The following code doesn't
work but it might show what I'm trying to do.

\def\bar#1{%
\directlua {
out(#1)
}}
\bar{\hbox{a}}

How can this be done?

Ciao
Andreas

`